Hi,

I think your main problem here is that you use Int in the pattern matching.
The point is that you are matching your value of type Tree k v to a pattern such as:
- EmptyTree
- (Node (a, b) left right)

Patterns don't contain type information such as Int, but things like value constructors and variables.
Note the difference between type constructors and value constructors (http://book.realworldhaskell.org/read/defining-types-streamlining-functions.html).
So you probably should use something like this:

data Tree k v = EmptyTree
ššššššššššššššš | Node (k, v) (Tree k v) (Tree k v)

instance (Show k, Show v) => Show (Tree k v) where
šššš show EmptyTree =
šššššššš "Empty"
šššš show (Node (a, b) left right)š =
ššššššš show left ++ "(" ++ show a ++ "," ++ show b ++ ")" ++ show right

I probably use (++) too much here though.
'(Show k, Show v) =>' tells us that the types k and v are of that typeclass so that we can use show on values of this type.

I'm a beginner too though so I hope I was clear.



2011/7/21 แฬลหำมฮฤา <kommunist1917@mail.ru>
Hello, šthank you for reply. I know that i can derive this. But i want to know how can i make it by hand.

Thank you.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe