我被告知要编写一个函数来检查字符串中的标点符号是否都是空格。IE:
haskell> f "Hello my name is Brad"
True
haskell> f "Hello my name is Brad!"
False
我写了一个辅助函数如下,
import Data.Char
isPunc x = not (isDigit x || isAlpha x)
这被 Haskell 接受并且工作正常。但是一旦我在以下功能中使用它,
--function f defined
f :: String -> Bool
f xs = and [ x == ' ' | x <- xs, isPunc x]
它给了我这个错误:
ambiguous occurence 'isPunc', could mean "Main.isPunc" or "Data.Char. isPunc"
我得到了它抱怨的部分内容,但是导入了 Data.Char,我真的不明白它为什么抱怨。