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

Arseniy Alekseyev arseniy.alekseyev at gmail.com
Mon Jan 2 07:12:37 CET 2012


> I don't know what to actually do with this after putting it in a *.lhs file.

You can :load *.lhs into ghci the same way you load .hs-files.

I'm not sure why you were getting the ambiguous type errors. I didn't:

test1 :: StateT Integer Identity (Integer, Integer)
test2 :: StateT [Char] Identity ([Char], [Char])
test3 :: StateT Integer (StateT [Char] Identity) (Integer, [Char])
test5 :: StateT Integer IO ()
test7 :: StateT Integer (StateT [Char] Identity) (Integer, [Char])

Hope that helps.
Arseniy.

On 2 January 2012 06:03, Steve Horne <sh006d3592 at blueyonder.co.uk> wrote:
> 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...
>
> http://blog.sigfpe.com/2006/05/grok-haskell-monad-transformers.html
>
> 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!!!
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list