[Haskell-cafe] systemtimmetypeable: Workaround for lack of deriveable data instance in either System.Time or Data.Time.

0 views
Skip to first unread message

Thomas Hartman

unread,
Oct 19, 2009, 5:00:36 PM10/19/09
to Haskell Cafe, HAppS
At

http://osdir.com/ml/haskel...@haskell.org/2009-10/msg00197.html

I griped that the lack of Data-Derivable time values was causing me
headache in happstack.

In the proposed cabal package

http://patch-tag.com/r/tphyahoo/systemtimetypeable/snapshot/current/content/pretty/systemtimetypeable.cabal

I submit a workaround that, while probably not the ideal thing, has
proved helpful to me.

Basically, I use the type MyTime, which is data-deriveable, when
working with Macid in happstack; and convert from System.Time and/or
Data.Time with the accompanying utility functions when necessary.
Perhaps the utility functions are useful on their own as well. I found
it surprisingly hard to get from Data.Time values to System.Time
values.

Anyways, I am interested in what others think and, of course, patches
and suggestions welcome.

thomas.
_______________________________________________
Haskell-Cafe mailing list
Haskel...@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Thomas Hartman

unread,
Oct 21, 2009, 12:15:52 PM10/21/09
to Haskell Cafe, HAppS, ash...@semantic.org, wou...@chalmer.se
update:

on haskell reddit, dons suggested simply patching time. reasonable
enough, but I hit a glitch where the Data.Fixed (in base lib) was
missing a Data instance, and gave up when I couldn't find the source
repo for base. Is this simply part of ghc?

Anyways, that instance seems to be added in ghc 6.12 so probably a non
issue now or closer to it.

http://www.haskell.org/ghc/dist/current/docs/html/libraries/base/Data-Fixed.html

also, aavogton #haskell suggested

http://hpaste.org/fastcgi/hpaste.fcgi/view?id=11009#a11009

as a workaround for people using time on happstack earlier than 6.12,
probably nicer than the MyTime hack I created though it comes with a
bit more baggage.

I haven't upgraded to 6.12 but I would suggest that time now be made
Data Generics friendly if it hasn't already, since this is probably a
very simple change and would be helpful to happstack. If no one has
time to do this I'll try to get around to it when I upgrade to 6.12.

Also wouter swierstra suggested that standalone deriving (
http://www.haskell.org/ghc/docs/latest/html/users_guide/deriving.html#stand-alone-deriving
) could be helpful in this case but I'm not sure why, or even whether
this was for data-izing data.time or system.time or both.

Given all this I won't be uploading anything to hackage, and hopefully
the base libs + time will be data friendly soon enough.

thomas.

2009/10/19 Thomas Hartman <tphy...@gmail.com>:

Ashley Yakeley

unread,
Oct 21, 2009, 1:05:18 PM10/21/09
to Thomas Hartman, wou...@chalmer.se, HAppS, Haskell Cafe, ash...@semantic.org
Data.Fixed (in base) has been updated with Data instances in HEAD. When
that's released, I'll release time-extra that will contain Data
instances. I've got it all ready to go.

The reason Data instances are in time-extras is that the time library
must be Haskell 98, while Data instances require Rank2.

-- Ashley

Reply all
Reply to author
Forward
0 new messages