源代码的定义`==`对于haskell中的列表
有谁知道 ==
是如何定义为Haskell中的列表定义的吗?我已经尝试将其调整为hoog,但似乎找不到实例eq [a]
的定义位置。
Does anyone know how exactly ==
is defined for lists in Haskell? I've tried Hoogling it but can't seem to find where the instance Eq [a]
is defined.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
eq
的GHC实现和其他内置实例是用ghc.classes
。具体来说,您正在寻找eq [a]
没有什么超级令人兴奋的。两个空列表相等,如果头部和尾巴相等,则两个非空列表相等。最后,两个任意列表是非平等的。唯一有趣的部分是专业指令,该指令应在整数列表,字符串和字符串列表上进行单态化。
The GHC implementation of
Eq
and other built-in instances is written inGHC.Classes
. Specifically, you're looking forEq [a]
Nothing super exciting. Two empty lists are equal, and two nonempty lists are equal if the heads and tails are equal. Finally, two arbitrary lists are non-equal. The only interesting part is the specialization directives, which should monomorphize equality checks on integer lists, strings, and lists of strings.