[Haskell-cafe] Monad for binary tree data structure
Александр
kommunist1917 at mail.ru
Sat Jul 23 07:31:23 CEST 2011
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110723/6bed6eec/attachment.htm>
More information about the Haskell-Cafe
mailing list