[Haskell-cafe] Grok Monad Transformers - some help needed
allbery.b at gmail.com
Mon Jan 2 12:28:45 CET 2012
On Mon, Jan 2, 2012 at 03:32, Steve Horne <sh006d3592 at blueyonder.co.uk>wrote:
> BTW - interesting how the signatures of test1 and test2 are reported - I
> hadn't realised monad transformers were relevant there. Of course it does
> seem a bit silly to implement both StateT and State when StateT can
> implement State for you.
If you're using the mtl1 library, State is separate from StateT. With the
transformers library (or mtl2, which is a wrapper for transformers) State
is defined as StateT Identity. Part of the reason for this is that older
ghc didn't optimize very well with something like StateT Identity; part is
simply because monad transformers came later and nobody bothered to go back
and rework the standalone monads as transformers over an Identity monad.
The original Monad library included non-transformer-based multi-monads
such as RWS (Reader+Writer+State) as well, since nobody has worked out
transformers as a concept yet.
brandon s allbery allbery.b at gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe