[Haskell-cafe] New to Monads

Tom Hawkins tom at confluent.org
Thu Oct 6 23:08:40 EDT 2005

I'm just starting to feel comfortable working inside IO; now I am trying 
to wrap my head around Control.Monad.State.  Looking at the 
implementation, I came across some unfamiliar syntax...

class (Monad m) => MonadState s m | m -> s where

What is the meaning of "| m -> s"?  I found no mention of it in the 

And slight logical dilemma...

With IO, I understand one your in it, you can't get out.  I.e., any 
function that conducts IO must have IO _ in the type signature.

But this must not apply to all monads, otherwise the type signature for 
"main" would be rather messy (IO + State + every other monad used in a 
program).  But I don't see how a monad could escape this fate since bind 
and return only produce more monads with the same type constructor.

Thanks for your help!


More information about the Haskell-Cafe mailing list