[Haskell-beginners] N-ary tree search problems

Ryan Temple ryantemple145 at googlemail.com
Wed Nov 4 07:04:08 EST 2009


I'm making a general purpose N-ary tree and im coming up with "unexpected
'=' on line 17" as an error.  I have spent a fair while trying to work out
why this isn't accepting the case that an Empty gtree returns false for any
member search.  i realise this is probably a very trivial error but any help
would be appreciated:

module GTrees where

data Gtree = Empty |
             Leaf String |
             Node String [Gtree]
             deriving (Show)

--Tests if a given string is a member of the tree

gtreeMember :: (Ord a) => a -> Gtree a -> Bool
  gtreeMember y Empty = False  -- line 17
  gtreeMember y (Leaf x) = (x==y)
  gtreeMember y (Node x tree)
      |x==y = True
      |otherwise gtreeMember tree

This is the code up to the point of the error with the error line
highlighted
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20091104/18de551b/attachment.html


More information about the Beginners mailing list