[Haskell-beginners] help with IO guards

Marcin Mrotek marcin.jan.mrotek at gmail.com
Thu Jan 15 21:03:35 UTC 2015


Hello,

A list ([]) is also a monad, and a String is defined as a list of
characters ([Char]). So in your example, it's as if you were trying to
use (>>=) operator on two different monads ([] and IO), which is
impossible. To make a pure value a monadic value, you need to use
return:

g = readLn >>= (\a -> return (f a))

which is equivalent to composing f with return:

g = readLn >>= return.f

Regards,
Marcin


More information about the Beginners mailing list