小编And*_*kyi的帖子

当模式匹配函数列表时,没有 (Eq ([a] -> [a])) 的实例

考虑以下代码:

step :: [[a] -> [a]] -> [[a]] -> [[a]]
step (f:fs) xss
  | (fs == []) = yss
  | otherwise = step fs yss
  where yss = map f xss
Run Code Online (Sandbox Code Playgroud)

它引发以下错误:

No instance for (Eq ([a] -> [a])) arising from a use of ‘==’
  (maybe you haven't applied a function to enough arguments?)

  |
3 |   | (fs == []) = res
  |      ^^^^^^^^
Run Code Online (Sandbox Code Playgroud)

fs 应该是一个函数列表或一个空列表,那么为什么编译器试图用它来制作一个函数呢?

haskell equals instance

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

标签 统计

equals ×1

haskell ×1

instance ×1