我创建了一段代码:
intToDigit :: Char -> Int
ord :: Char -> Int
intToDigit c = ord c - ord 'a'
但是,当我运行它时,我收到以下错误消息:
ChangeVowels.hs:2:1: The type signature for `ord' lacks an accompanying binding
ChangeVowels.hs:4:16: Not in scope: `ord'
ChangeVowels.hs:4:24: Not in scope: `ord'
我试过
Import data.char
但这也不起作用。
最佳答案
您需要提供函数 ord
的实现.在这里,您已为 ord
签名。 ,但没有实现。
或者你可以使用 Haskell 自己的 ord
函数,即Char.ord
.
关于Haskell 错误 : "lacks an accompanying binding" and "not in scope",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5371261/