小编Aid*_*kus的帖子

Haskell错误:无法将类型'a'与'b'匹配

我是Haskell的新手并拥有这段代码:

import Control.Monad

data NestedList a = Elem a | List [NestedList a] deriving (Show)

instance Monad NestedList where
    return a = List [Elem a]
    (List (Elem a: xs)) >>= f = let a' = f a in a' `joinLists` xs

func :: a -> NestedList a
func a = List ([Elem a] ++ [Elem a])

joinLists :: NestedList a -> [NestedList a] -> NestedList a
joinLists (List a) b = List (a ++ b)

main = do let a …
Run Code Online (Sandbox Code Playgroud)

haskell

4
推荐指数
1
解决办法
912
查看次数

标签 统计

haskell ×1