You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
instance Num Int where<br />
plus = plusInt#<br />
InstDecl<br />
[]<br />
(Name ”Num”)<br />
(TCon AlgTyCon { tyId = Name ”Int” })<br />
[ FunDecl<br />
BindGroup<br />
{ _matchName = Name ”plus”<br />
, _matchPats =<br />
[ Match { _matchPat = [] , _matchBody = EVar (Name ”plusInt”) } ]<br />
, _matchType = Nothing<br />
, _matchWhere = [ [] ]<br />
}<br />
]<br />
Wired-in Types<br />
While the base <strong>Haskell</strong> is quite small, several portions of the desugaring process require the compiler<br />
to be aware about certain types before they otherwise defined in the Prelude. For instance the type of<br />
every guarded pattern in the typechecker is Bool. ese are desugared into a case statement that includes<br />
the True and False constructors. e Bool type is therefore necessarily baked into the syntax of the<br />
language and is inseparable from the implementation.<br />
sign x<br />
| x > 0 = 1<br />
| x == 0 = 0<br />
| x < 0 = -1<br />
ese are called the wired-in types, and while they are still defined in our Prelude they will have somewhat<br />
special status. e primitive types (of kind #) will be very special and are not user extensible, they map<br />
directly to implementation details of the code generation backend or <strong>Haskell</strong> functions hard-wired into<br />
the interpreter.<br />
Syntax Name Kind Description<br />
Int# Int# # Machine integer<br />
Char# Char# # Machine char<br />
Double# Double# # Machine double<br />
Addr# Addr# # Heap address<br />
Int Int * Boxed integer<br />
Char Char * Boxed char<br />
Double Double * Boxed double<br />
[] List * -> * List<br />
124