[Haskell-beginners] using the current time

Edward Z. Yang ezyang at MIT.EDU
Tue Dec 8 18:33:30 EST 2009

Excerpts from Torsten Otto's message of Tue Dec 08 18:18:54 -0500 2009:
> > time = formatiereZeit (NOW WHAT?)
> Would the current time step out of the IO monad, please?

Unfortunately, there is no way to "step out" of the IO monad:
once in the IO monad, always in the IO monad.

However, if you let time be of type IO String instead of String,
you can do:

    time = (liftM formatiereZeit) getClockTime

Where liftM :: (a -> b) -> m a -> m b, i.e. it converts
your function ClockTime -> String into IO ClockTime -> IO String.


More information about the Beginners mailing list