<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif;font-size:small">Thanks Max!! </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 14, 2015 at 4:57 PM, Max Voit <span dir="ltr"><<a href="mailto:max.voit+mlhb@with-eyes.net" target="_blank">max.voit+mlhb@with-eyes.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thu, 14 May 2015 16:27:46 +0530<br>
Dananji Liyanage <<a href="mailto:dan9131@gmail.com">dan9131@gmail.com</a>> wrote:<br>
<br>
> Correct me if I'm doing something wrong here. Here's my code:<br>
><br>
>            main = do<br>
>                   now <- getCurrentTime<br>
>                   diffUTCTime now bree<br>
>           bree = readMay "1981-06-16 04:35:25" :: UTCTime<br>
<br>
</span>There are several problems with that code. First what the compiler is<br>
complaining about: Last statement in a do-block must have type of the<br>
block, in this case IO () - so print it or return ()<br>
<br>
For the readMay - this is expected to return Maybe UTCTime. To stuff<br>
this into diffUTCTime you need to get it out of the Maybe.<br>
<br>
For my formulation "is expected to" - it won't, as UTCTime has no Read<br>
instance (so you can't call read on it). Take a look at ParseTime and<br>
its buildTime method.<br>
<br>
cheers, max<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div><div><font face="georgia,serif">Regards, <br>Dananji Liyanage</font></div></div></div></div></div>
</div>