Quantcast
Channel: Pragmatic Forums | Posts in topic 'drunken-monad identity monad example'
Viewing all articles
Browse latest Browse all 22

drunken-monad identity monad example posted by Leo @ Sun, 06 Mar 2011 05:42:14 +0000

$
0
0

in looking at the body of the treasureMap function on page 304 (“Building a Monad from Scratch”), I am trying to figure out how to parse the expression:

pos >>==
stagger>>==
stagger>>==
crawl>>==
rtn

how is this parsed by GHC? (right associative or left associative >>==)
Like this(right associative >>==)?

pos >>==
(stagger>>==
(stagger>>==
(crawl>>==
rtn)))

or like this(left associative >>==)?

(((pos >>==
stagger>>==)
stagger>>==)
crawl>>==)
rtn

The first(right-associative) would seem to transform like so:
form0: pos >>== (stagger>>== (stagger>>== (crawl>>== rtn)))
...form1: (stagger>>== (stagger>>== (crawl>>== rtn))) (pos)
...form2 (stagger>>== (crawl>>== rtn)) (stagger (pos))
...form3 (crawl>>== rtn) (stagger (stagger (pos)))
....form4 rtn (crawl (stagger (stagger (pos))))

I think I fudged it a bit to make the parentheses work right. My confusion is, for example, in step :
what does (crawl>>==rtn) mean? This can’t be right since crawl>>==return evaluates to return(crawl). Either I’m missing some sort of function composition operator in my rewriting or my transformation is wrong.

Thanks for your help


Viewing all articles
Browse latest Browse all 22

Trending Articles