本文介绍了Haskell 错误:“缺少随附的绑定"和“不在范围内"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创建了一段代码:
I have created a piece of code this:
intToDigit :: Char -> Int
ord :: Char -> Int
intToDigit c = ord c - ord 'a'
但是,当我运行它时,我收到此错误消息:
However, when I run it I get this error message:
ChangeVowels.hs:2:1:`ord' 的类型签名缺少伴随的绑定
ChangeVowels.hs:4:16: 不在范围内:`ord'
ChangeVowels.hs:4:16: Not in scope: `ord'
ChangeVowels.hs:4:24:不在范围内:`ord'
ChangeVowels.hs:4:24: Not in scope: `ord'
我用 Import data.char
试过了,但也不管用.
I tried it with Import data.char
but that doesnt work either.
推荐答案
您需要为 ord
函数提供一个实现.在这里,您已经为 ord
提供了一个签名,但没有实现.
You need to provide an implementation for the function ord
. Here, you have given a signature for ord
, but no implementation.
或者你可以使用Haskell自带的ord
函数,即Char.ord
.
Or you can use Haskell's own ord
function, that is Char.ord
.
这篇关于Haskell 错误:“缺少随附的绑定"和“不在范围内"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!