[Haskell-cafe] Monad for binary tree data structure

Александр kommunist1917 at mail.ru
Sat Jul 23 09:04:37 CEST 2011


Hello,

>1) Do you really need a Monad instance for this?

Only for training purposes.

2) One possibility is just have it being (Node x _ _) >>= f = f x

I've already tried to do so, but i get only 1 element. Look.

I have a function fillTree that's fill this binary tree.

let a = fillTree 1 Empty

a >>= \x -> return (x * 2)

I got:

Node 2 Empty Empty

But i have tree with 100 elements.

Thank you.



Thank you.


More information about the Haskell-Cafe mailing list