data Tree a = Node { key :: a
, left :: Tree a
, right :: Tree a
}
| Leaf
instance Show a => Show (Tree a) where
show t @ (Node {}) =
"Node{" ++ "key=" ++ show (key t) ++ ","
++ "left=" ++ show (left t) ++ ","
++ "left=" ++ show (left t) ++ "}"
show Leaf = "Leaf"
Das kann der Compiler selbst:
data Tree a = ... deriving Show