[Haskell-beginners] Date Time in Haskell

Dananji Liyanage dan9131 at gmail.com
Thu May 14 11:54:26 UTC 2015


Thanks Max!!

On Thu, May 14, 2015 at 4:57 PM, Max Voit <max.voit+mlhb at with-eyes.net>
wrote:

> On Thu, 14 May 2015 16:27:46 +0530
> Dananji Liyanage <dan9131 at gmail.com> wrote:
>
> > Correct me if I'm doing something wrong here. Here's my code:
> >
> >            main = do
> >                   now <- getCurrentTime
> >                   diffUTCTime now bree
> >           bree = readMay "1981-06-16 04:35:25" :: UTCTime
>
> There are several problems with that code. First what the compiler is
> complaining about: Last statement in a do-block must have type of the
> block, in this case IO () - so print it or return ()
>
> For the readMay - this is expected to return Maybe UTCTime. To stuff
> this into diffUTCTime you need to get it out of the Maybe.
>
> For my formulation "is expected to" - it won't, as UTCTime has no Read
> instance (so you can't call read on it). Take a look at ParseTime and
> its buildTime method.
>
> cheers, max
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>



-- 
Regards,
Dananji Liyanage
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150514/829ebbb5/attachment.html>


More information about the Beginners mailing list