小编rgr*_*lma的帖子

(show a)的任何实例均不因使用“ show”而产生

在((++))的第一个参数中,“ 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)

haskell show

3
推荐指数
1
解决办法
90
查看次数

标签 统计

haskell ×1

show ×1