[Haskell-cafe] RE: [Haskell] Monad and Monad transformer???

Simon Peyton-Jones simonpj at microsoft.com
Mon May 7 04:30:38 EDT 2007


As someone mentioned, don't worry about being new to Haskell, but DO send your messages to haskell-cafe at haskell.org, not the main Haskell list.  I'm redirecting this so that the Helpful Denizens of the Haskell Cafe can help you.

Simon

| -----Original Message-----
| From: haskell-bounces at haskell.org [mailto:haskell-bounces at haskell.org] On Behalf Of Duong Thai Ha
| Sent: 06 May 2007 17:03
| To: haskell at haskell.org
| Subject: [Haskell] Monad and Monad transformer???
|
| hi
| I am a newbee to haskell so please forgive me if the question is not
| appropreate.
|
| I am trying to get the idea of using Monad and have to understand the
| following code.
|
| Can you please tell me is how different Monad and Monad transformer is?
| And what is mean by
|
|  > newtype State s a = State { runState :: s -> (a, s) }
|
| ---------------------------------
|
| Define (State s) as a State monad
|
|  > instance Monad (State s) where
|  >    return a = State $ \s -> (a,s)
|  >    m >>= k  = State $ \s -> let (a,s') = runState m s in runState (k
| a) s'
|
| Thanks  lot for your help
| I really do appreciate that
|
| Best regard
| _______________________________________________
| Haskell mailing list
| Haskell at haskell.org
| http://www.haskell.org/mailman/listinfo/haskell


More information about the Haskell-Cafe mailing list