Data.Time.Calendar.Day does not seem to have an instance for Read

Hi, I was wondering if this is a defect - Prelude> import Data.Time.Calendar Prelude Data.Time.Calendar> read "2011-10-10" :: Day <interactive>:1:1: No instance for (Read Day) arising from a use of `read' Possible fix: add an instance declaration for (Read Day) In the expression: read "2011-10-10" :: Day In an equation for `it': it = read "2011-10-10" :: Day Prelude Data.Time.Calendar> The documentation says that Day has an instance for Read. Regards, Kashyap

On Thu, Mar 17, 2011 at 12:30 AM, C K Kashyap
Hi, I was wondering if this is a defect - Prelude> import Data.Time.Calendar Prelude Data.Time.Calendar> read "2011-10-10" :: Day <interactive>:1:1: No instance for (Read Day) arising from a use of `read' Possible fix: add an instance declaration for (Read Day) In the expression: read "2011-10-10" :: Day In an equation for `it': it = read "2011-10-10" :: Day Prelude Data.Time.Calendar>
I see the same problem with GHC 7.0.2, time-1.2.0.3. Does it work if you use it in a Haskell source file, instead of GHCi? Thanks, Antoine
The documentation says that Day has an instance for Read. Regards, Kashyap _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Thu, Mar 17, 2011 at 12:30 AM, C K Kashyap
wrote: Hi, I was wondering if this is a defect - Prelude> import Data.Time.Calendar Prelude Data.Time.Calendar> read "2011-10-10" :: Day <interactive>:1:1: No instance for (Read Day) arising from a use of `read' Possible fix: add an instance declaration for (Read Day) In the expression: read "2011-10-10" :: Day In an equation for `it': it = read "2011-10-10" :: Day Prelude Data.Time.Calendar>
I see the same problem with GHC 7.0.2, time-1.2.0.3.
Does it work if you use it in a Haskell source file, instead of GHCi?
Thanks, Antoine
Nope, even compiling with ghc causes the error. Regards, Kashyap

On Thu, Mar 17, 2011 at 07:30, C K Kashyap
On Thu, Mar 17, 2011 at 12:30 AM, C K Kashyap
wrote: Hi, I was wondering if this is a defect - Prelude> import Data.Time.Calendar Prelude Data.Time.Calendar> read "2011-10-10" :: Day <interactive>:1:1: No instance for (Read Day) arising from a use of `read' Possible fix: add an instance declaration for (Read Day) In the expression: read "2011-10-10" :: Day In an equation for `it': it = read "2011-10-10" :: Day Prelude Data.Time.Calendar>
I see the same problem with GHC 7.0.2, time-1.2.0.3.
Does it work if you use it in a Haskell source file, instead of GHCi?
Nope, even compiling with ghc causes the error.
So then it's not a bug. The instance is defined in Data.Time.Format.Parse, and Data.Time.Calendar doesn't import that module. This, however is a bug, I think: Prelude> import Data.Time Prelude Data.Time> read "2011-10-10" :: Day ... no instance for (Read Day) ... Prelude> :m +Data.Time Prelude Data.Time> read "2011-10-10" :: Day 2011-10-10 Erik

So then it's not a bug. The instance is defined in Data.Time.Format.Parse, and Data.Time.Calendar doesn't import that module.
This, however is a bug, I think:
Prelude> import Data.Time Prelude Data.Time> read "2011-10-10" :: Day
... no instance for (Read Day) ...
Prelude> :m +Data.Time Prelude Data.Time> read "2011-10-10" :: Day 2011-10-10
Erik
Thanks Erik.
participants (3)
-
Antoine Latter
-
C K Kashyap
-
Erik Hesselink