[Haskell-cafe] Grok Monad Transformers - some help needed

Steve Horne sh006d3592 at blueyonder.co.uk
Mon Jan 2 07:03:57 CET 2012

I'm having another go at figuring out Monad Transformers, starting at 
the same point I've started and stopped the last couple of times. That's 
this tutorial...


Onion layers, lift etc - I get that. But I've never actually got 
anything to work - and therefore never built the confidence to move on.

Problem 1 - this is literate Haskell. I've tried feeding it to haddock - 
all I get is an error about it lacking a main. I don't know what to 
actually do with this after putting it in a *.lhs file.

No big deal, but...

Problem 2 - even cutting the code out, shoving it in a *.hs file, and 
:loading it into GHCi, I still get a lot of errors.

For the functions test1 and test2, the fixes were explicit type 
signatures. Easy enough to figure out...

   test1 :: State Int (Int, Int)
   test2 :: State String (String, String)

I guess the basic issue is the same with test3 (and though I haven't 
tried the others today, probably test5 and test7 too). The trouble there 
is that I don't know what those type signatures should be because I 
don't know that much about monad transformers and how they can work. I 
can see what's going on in the body of test3, but that is a very small 
amount of understanding - the type signatures are important. And I can't 
use :type because GHCi is rejecting the code.

In short... HELP!!!

More information about the Haskell-Cafe mailing list