I'm implementing the insert function of a BST, below is my code:
data Tree a = Empty | Branch a (Tree a) (Tree a)
deriving (Show, Eq)
tinsert :: Tree a -> a -> Tree a
tinsert Empty a = Branch a Empty Empty
tinsert (Branch a left right) b
| b == a = Branch a left right
| b < a = Branch a (tinsert left b) right
| b > a = Branch a left (tinsert right b)
When I was loading this function in ghci, it gave me many errors, which seem to be related to the comparison parts. I don't see any problem with it. I'm new to Haskell, could anybody help? Thanks a lot.