
hello, i still seaching a good monad example and after passed the classic tutorial about Maybe monad or State monad which is found in almost 90% of the litterature i try to learn in deep the example of monad that talk about probability ( http://learnyouahaskell.com/for-a-few-monads-more ) for this i try to trace the calls of the inner monad definition like in the file, i give the file in attachment (monade.hs) and the output has a lot of garbage data, not the nicer way to display it,sorry. What i can not figure out is at what stage the program construct the [Tails,Heads] , [Heads,Heads] ... etc i do not know, if someone could explain me in detail the action of a <- coin b <- loadedCoin return [a,b] step by step it would be of great help... Regards, Damien note: here is the ouput: *Main> :load monade.hs [1 of 1] Compiling Main ( monade.hs, interpreted ) Ok, one module loaded. *Main> flipTwoVal Prob {getProb = (Monad Prob >>= flatten (fmap f m) Functor Prob Functor Prob (f x,1 % 2) flatten multAll map ... p= 1 % 2 (Monad Prob >>= flatten (fmap f m) Functor Prob Functor Prob (f x,1 % 10) flatten multAll map ... p= 1 % 10 Monad Prob return) [ flatten multAll (1 % 10*1 % 1) flatten multAll (1 % 2*1 % 10) ([Heads,Heads],1 % 20) Functor Prob (f x,9 % 10) flatten multAll map ... p= 9 % 10 Monad Prob return) , flatten multAll (9 % 10*1 % 1) flatten multAll (1 % 2*9 % 10) ([Heads,Tails],9 % 20) Functor Prob (f x,1 % 2) flatten multAll map ... p= 1 % 2 (Monad Prob >>= flatten (fmap f m) Functor Prob Functor Prob (f x,1 % 10) flatten multAll map ... p= 1 % 10 Monad Prob return) , flatten multAll (1 % 10*1 % 1) flatten multAll (1 % 2*1 % 10) ([Tails,Heads],1 % 20) Functor Prob (f x,9 % 10) flatten multAll map ... p= 9 % 10 Monad Prob return) , flatten multAll (9 % 10*1 % 1) flatten multAll (1 % 2*9 % 10) ([Tails,Tails],9 % 20)]} *Main> flipTwoVal Prob {getProb = [([Heads,Heads],1 % 20),([Heads,Tails],9 % 20),([Tails,Heads],1 % 20),([Tails,Tails],9 % 20)]}