[Haskell-beginners] Guard in class def

Henry Lockyer henry.lockyer at ntlworld.com
Sun Jan 8 10:29:51 CET 2012


Hi,
I was just looking through the 'Monad Transformers' chapter in Real World Haskell. They are using the "reader" monad to illustrate the transformer structure  but I fell off at the first bend when I saw the following:

class (Monad m) => MonadReader r m | m -> r where
  ask     :: m r
  local  :: (r -> r) -> m a -> m a


Could someone explain the use of a guard here / how to read this with the "| m -> r"  ?  
I haven't come across this usage before (as far as I have noticed :-) and the meaning hasn't jumped out at me yet...

Thanks in advance.

Henry


More information about the Beginners mailing list