Haskell 错误 : "lacks an accompanying binding" and "not in scope"

标签 haskell compiler-errors

我创建了一段代码:

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/

相关文章:

haskell - 是否可以使用 Ghcjs、Haste、Elm 等在服务器端渲染 Haskell 前端?

haskell - 在Maybe中从(Just x)中提取x

javascript - 将编译的 Julius 模板公开为单独的文件,而不是直接将它们放入 DOM 中

haskell - 通过堆栈安装特定版本

java - 找不到符号变量 key1

arrays - Haskell 数组(矩阵)元素访问

compiler-errors - Fortran MPI-无法在新服务器上使用现有代码库

c# - 使用接口(interface)对字典条目类型的正确性进行编译时检查

java - 为什么我在 Java 中收到 Unreachable Statement 错误?

c++ - 尝试解析 Boost Spirit 语法时出现编译时错误