[Haskell-beginners] My own State Monad and State Arrow

Thiago Negri evohunz
Thu Oct 3 01:34:23 UTC 2013


I think I did understand Monads and Arrows.
So I put it to the test: I tried to write my own State Monad and an State
Arrow without looking at the real implementation.

This is what I got: http://lpaste.net/93801

Please take a look on line 146 where I try to define a State Monad that is
represented with a full function (state+result -to- state+result -- like my
Arrow implementation).
Things got hairy with the bind operator (line 153) and I just hit the
keyboard until I hit the correct types and got it to compile.
Yet, I can't fully understand my own bind implementation.
Using the result "a" twice seems to be wrong, but I couldn't write a test
to prove it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20131002/69277cc6/attachment.html>



More information about the Beginners mailing list