我是函数式编程和 CLEAN 的新手。我有一些功能,但我有一个错误,我不知道为什么。(我用 Haskell 标记了它,因为它与 CLEAN 非常相似。)
我的模块:
module Prac
combine :: (Maybe a) (Maybe [a]) -> Maybe [a]
combine Nothing _ = Nothing
combine _ Nothing = Nothing
combine (Just d) (Just [x:xs]) = Just [d, x:xs]
sequence :: [Maybe a] -> Maybe [a]
sequence [Just x:xs] = combine (Just x) Just[xs]
它在序列定义中失败:
Type error [Prac.icl,32,sequence]: near combine : cannot unify types:
[v8] -> Maybe [v4]
Maybe [v5]
非常感谢!!