在((++))的第一个参数中,“ show a”的使用不会导致(Show a)的实例。
data LTree a = Leaf a | Node (LTree a) (LTree a)
instance Show (LTree a) where
show (Leaf a) = "{" ++ show a ++ "}"
show (Node fe fd) = "<" ++ (show fe)++ "," ++(show fd)++ ">"
Run Code Online (Sandbox Code Playgroud)
Node (Leaf 1) (Node (Node (Leaf 3) (Leaf 4)) (Node (Leaf 8) (Leaf 7)))
Run Code Online (Sandbox Code Playgroud)
我应该得到:
<{1},<<{3},{4}>,<{8},{7}>>>
Run Code Online (Sandbox Code Playgroud)