Hello,

I built binary tree with:


data Tree a = Empty  
              | Node a (Tree a) (Tree a) 
              deriving (Eq, Ord, Read, Show)

How can i make Monad type class instance for this tree? And can i make it on 
not?

i try:


instance Monad Tree where
    return x = Node x Empty Empty 
    Empty >>= f = Empty
    (Node x Empty Empty) >>= f = f x 

But i can't make (>>=) for Node x left right. 
Thank you. 
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to