2011/7/23 Александр <[email protected]>: > 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
1) Do you really need a Monad instance for this? 2) One possibility is just have it being (Node x _ _) >>= f = f x -- Ivan Lazar Miljenovic [email protected] IvanMiljenovic.wordpress.com _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
