Haskell:不在范围内:数据构造函数 [英] Haskell: Not in scope: data constructor
本文介绍了Haskell:不在范围内:数据构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
继承人代码:
ff :: [[Char]] - > [[Char]] - > [Char]
ff A B = [[x !! 0,y! 1] | x <-A,y <-B,(x !! 1)==(y !! 0)]
和错误:
md31.hs:2:4:不在范围内:数据构造函数`A'
md31.hs:2:6:不在范围内:数据构造函数`B'
md31.hs:2:38:不在范围内:数据构造函数`A'
md31.hs:2:46:不在范围内:数据构造函数`B'
预先感谢:)
解决方案
函数参数必须以Haskell中的小写字母开头。
因此,您需要使 A
和 B
小写( a
和 b
)在您的函数定义中。
如果标识符的第一个字母是大写字母,则假定它是数据构造函数。
Started to learn haskell today for school and I run into a problem with function. I don't understand why it's not in the scope..
Heres the code:
ff :: [[Char]] -> [[Char]] -> [Char]
ff A B = [[x !! 0, y !! 1] | x <- A, y <- B, (x !! 1) == (y !! 0)]
And errors:
md31.hs:2:4: Not in scope: data constructor `A'
md31.hs:2:6: Not in scope: data constructor `B'
md31.hs:2:38: Not in scope: data constructor `A'
md31.hs:2:46: Not in scope: data constructor `B'
Thanks in advance :)
解决方案
Function parameters have to start with a lowercase letter in Haskell.
As such, you'd need to make A
and B
lowercase (a
and b
) in your function definition.
If the first letter of an identifier is in uppercase, it is assumed to be a data constructor.
这篇关于Haskell:不在范围内:数据构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文