且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

编译时出现Haskell类型错误

更新时间:2022-12-07 07:36:25

The code you gave has a few errors.

  1. As @FramkSchmitt mentioned there is a parameter xs missing.
  2. you try to map elem x over a list - which would need a list of lists to be correct.

here is what I would guess what you intended.

members :: Code -> Bool
members xs = and [ x `elem` symbols  | x <- xs ]

which can be written a bit more concise (I believe tools like hlint would even suggest this simplification).

members' :: Code -> Bool
members' = all (`elem` symbols)

相关阅读

技术问答最新文章