
related question: is this also an example of para morphism?
here is my current understanding
cata morphism -> fold/reduce [ e.g. list of numbers -> sum of numbers]
ana morphism -> unfold/reproduce depending on input [ e.g. one number ->
list of reapeated instances of same number]
some functions like map can be written both as a cata and as an ana.
hylo morphism -> ana followed by cata [ e.g. recursion trees of function
calls are ana, and the return path to the final evaluation is cata]
para morphism -> kind of ana but depends on input and output generated so
far fib, fact etc?
Im not sure i understood the last one well.
Thanks
Cheers
Ram
On Mon, Sep 13, 2010 at 11:42 AM, Alex Rozenshteyn
I'm trying to build a list where each entry depends on the previous one. Unfoldr seemed like a good idea at the time. Unfortunately, my values are monadic values (specifically RVars, from the random-fu package). Okay, shouldn't be a problem; I just monadic bind and...
-- example code updateCell :: Bool -> RVar Bool updateCell False = return False updateCell True = bernoulli (0.9 :: Double)
sim = sequence $ take 20 $ unfoldr (\x -> Just (x, x >>= updateCell)) (return True)
runRVar sim DevURandom
[True,True,True,True,True,False,True,False,True,False,False,False,False,False,False,True,True,False,False,False]
That output shouldn't be possible if I'm doing things right... It appears that each cell has an independent history. I'm stumped. Advice on threading monad input in general and random-fu in specific would be appreciated.
-- Alex R
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners