
On Fri, Aug 17, 2007 at 10:38:12AM +0200, Kai Grossjohann wrote:
The part that I'm having trouble with is monads and the associated operators (liftm comes to mind, it seems to be somehow related). I read Hal Daume's tutorial. Do you have advice what else I can read to grok?
(And I'm having trouble to understand the relationship between "<-" and "=". Apparently, "<-" somehow implies that "statements" are "executed" in some order. But Haskell tries really hard to hide the fact that there are statements and that there is such as thing as execution. As Haskell is based on lambda calculus, I am not surprised -- there are no statements and there is no order of execution in lambda calculus. So Haskell tries so hard to hide them that I can't find them...)
Hi Kay, may I point you to this? http://www.haskell.org/haskellwiki/The_Monadic_Way I wrote it when I was trying to grasp monads myself, with the hope to provide newcomers with a helpful guide through stuff like <-, >> and
=.
A monad is just a way to nest anonymous functions so that bound variables (<-) can be later used by other (nested) anonymous functions. And by nesting functions you can simulate an order of execution. The complexity of this operation is hidden by the "do" notation, where every new line is indeed an anonymous function. The advise I can give you is to try to re-implement monads (and later arrows, and so on), by reading the papers that discovered them. For monads I suggest this paper: P. Wadler, Monads for functional programming. http://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/baastad.pdf This is how I came to understand monads. Hope this helps Andrea