小编sod*_*unk的帖子

Haskell Newbie-发生检查:无法构造无限类型:a〜[a]

我试图做一个带有3个参数的函数“ tokenize”。main String,应该在自己的String中的字符字符串,以及要从字符串中删除的chars字符串。

tokenize :: String -> String -> String -> [String]
tokenize [] imp remm = []
tokenize str imp remm =   let chr = (head str) in
                          if elem chr imp then ([chr] : (tokenize (tail str) imp remm))
                          else if (elem chr  remm ) then (tokenize (tail str) imp remm)
                          else chr: (tokenize (tail str) imp remm)
Run Code Online (Sandbox Code Playgroud)

我收到此错误消息:

Occurs check: 
cannot construct the infinite type: a ~ [a]
Expected type: [a]
Actual type: [[a]]
Run Code Online (Sandbox Code Playgroud)

haskell

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

标签 统计

haskell ×1