[Haskell-cafe] background question about IO monad

Luke Palmer lrpalmer at gmail.com
Wed Feb 6 01:12:08 EST 2008

On Feb 5, 2008 9:44 PM, Uwe Hollerbach <uhollerbach at gmail.com> wrote:
>   lisp> (UTCtime)
>   "Wed Feb  6 03:57:45 UTC 2008"
> ---
>   lisp> (UTCtime 1.203e9)
>   "Thu Feb 14 14:40:00 UTC 2008"
> --
> But after that, it sure seems to me as if I've taken data out of the
> IO monad... haven't I? Given that the second alternative never entered
> doIOAction and that after both are done I have a string of characters,
> prettily formatted to indicate a time, that's what it feels like to
> this unwashed C programmer.

Formatting a time is a completely pure operation.  If you give the
time formatting function
the same timestamp, you always get the same string back.  It is
getting the *current* time
which is in the IO monad, since it "returns" different results
depending on at what time it is


More information about the Haskell-Cafe mailing list