GHC.Base
的来源在开头部分有说明
The overall structure of the GHC Prelude is a bit tricky...
So the rough structure is as follows, in (linearised) dependency order
GHC.Prim Has no implementation. It defines built-in things, and
by importing it you bring them into scope.
The source file is GHC.Prim.hi-boot, which is just
copied to make GHC.Prim.hi
GHC.Base Classes: Eq, Ord, Functor, Monad
Types: list, (), Int, Bool, Ordering, Char, String
但是,虽然
Ordering
在该源文件中定义,但 Ord
不是。 Prelude 文档页面没有 Ord
的源链接。它实际上在哪里定义? 最佳答案
Ord
(和 Eq
)在 GHC.Classes
包(它是 base 的依赖项)的 ghc-prim 模块(由 GHC.Base
导入)中定义。
关于haskell - GHC 库中的类 Ord 在哪里定义?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49084482/