有关“没有绑定的类型签名”的错误 [英] Error about "type signature with no binding"
本文介绍了有关“没有绑定的类型签名”的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Haskell中遇到了ASCII问题。
fromEnum :: Char - > Int
toEnum :: Int - > Char
offset :: Int
offset = fromEnum'A' - fromEnum'a'
toUpper :: Char - > char
toUpper ch = toEnum(fromEnum ch + offset)
这个脚本给出了一个错误:
类型签名'fromEnum'缺少相应的绑定
必须给出类型签名,其中'fromEnum被声明为
类型签名'toEnum'缺少相应的绑定
必须给出类型签名,其中'toEnum被声明为
解决方案
fromEnum
and toEnum
是标准函数
请试试这个:
offset :: Int
offset = fromEnum'A' - fromEnum'a'
toUpper :: Char - > Char
toUpper ch = toEnum(fromEnum ch + offset)
I have a problem with ASCII in Haskell.
fromEnum :: Char -> Int
toEnum :: Int -> Char
offset :: Int
offset = fromEnum 'A' - fromEnum 'a'
toUpper :: Char -> Char
toUpper ch = toEnum (fromEnum ch + offset)
This script gives an error:
The type signature 'fromEnum' lacks an accompanying binding
The type signature must be given where 'fromEnum is declared
The type signature 'toEnum' lacks an accompanying binding
The type signature must be given where 'toEnum is declared
解决方案
fromEnum
and toEnum
are standart functions
please try this:
offset :: Int
offset = fromEnum 'A' - fromEnum 'a'
toUpper :: Char -> Char
toUpper ch = toEnum (fromEnum ch + offset)
这篇关于有关“没有绑定的类型签名”的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文