Question about literals in the core-language
Simon Marlow
simonmar@microsoft.com
Tue, 14 Jan 2003 11:28:08 -0000
> I'm working at comparing the ghc-core-language with another=20
> lambda-calculus.
> This calculus has no unboxed values, but normal constructors=20
> are available.
> My problem is now: How can I represent the unboxed values in=20
> my calculus.
> More precisely: Can I represent the unboxed values by a finite set of
> constants,
> or include the literals also integers, which can be infinite?=20
> If that is the
> case,
> how are the (unboxed) integers represented in the ghc-core-language?
First, there is a distinction between unboxed and unlifted types. An
unlifted type is one who's domain of values does not include _|_. All
of GHC's primitive types(*) are unlifted.
An unboxed type is unlifted, but also it is not represented by a
pointer. Its representation depends on the type (eg. Int# is a 32- or
64-bit signed integral value).
Integers do not have associated primitive types. An Integer in GHC is
defined as
data Integer=09
=3D S# Int# -- small integers
| J# Int# ByteArray# -- large integers
Cheers,
Simon
(*) well, except for RealWorld, but that is Deeply Special anyway.