Most user-level Haskell types and functions provided by GHC (in particular those from the Prelude and GHC's Prelude extensions) are internally constructed from even more elementary types and functions. Most notably, GHC understands a notion of unboxed types, which are the Haskell representation of primitive bit-level integer, float, etc. types (as opposed to their boxed, heap allocated counterparts) - cf. "Unboxed Values as First Class Citizens."
The hardwired types of GHC are brought into scope by the module
PrelGHC
. This modules only exists in the form of a
handwritten interface file PrelGHC.hi-boot
,
which lists the type and function names, as well as instance
declarations. The actually types of these names as well as their
implementation is hardwired into GHC. Note that the names in this file
are z-encoded, and in particular, identifiers ending on zh
denote user-level identifiers ending in a hash mark (#
),
which is used to flag unboxed values or functions operating on unboxed
values. For example, we have Char#
, ord#
, and
so on.
As of (about) the development version 4.11, the types and various
properties of primitive operations are defined in the file primops.txt
(Personally, I don't think that the .txt
suffix is really
appropriate, as the file is used for automatic code generation).
The utility genprimopcode
generates a series of Haskell files from primops.txt
, which
encode the types and various properties of the primitive operations as
compiler internal data structures. These Haskell files are not complete
modules, but program fragments, which are included into compiler modules
during the GHC build process. The generated include files can be found
in the directory fptools/ghc/compiler/
and carry names
matching the pattern primop-*.hs-incl
. They are generate
during the execution of the boot
target in the
fptools/ghc/
directory. This scheme significantly
simplifies the maintenance of primitive operations.
Last modified: Wed Aug 8 19:29:12 EST 2001