[Yhc] Compiling Prelude.hs

Krasimir Angelov kr.angelov at gmail.com
Wed Jan 18 18:18:28 EST 2006


I have to deal with another hack this time. See the comment from IExtract.hs:

-- addPreludeTupleInstances is an efficiency hack.
-- It takes a long time to parse the Prelude.hi file, and adding large
-- numbers of tuple instances to the .hi file increases compile-times
-- by 30% or more.
-- Omitting them from the .hi file and adding them by hand here, therefore
-- gives a big time saving.

The problem is that all instances for tuples >3 aren't defined in the
prelude but the required type declarations are injected explicitly in
the IExtract.hs module. In this way no bytecode for them will be
generated. In Data.Ix are defined Ix instances for all tuples with
size up to 15. Since the Ix instance depends on Ord, when I am
compiling these Ix instances the byte code will have references to the
corresponding Ord instances but unfortunately they don't exist. This
is reported as missing reference from the assembler. I have fixed that
with some dummy instance declarations in Prelude.hs.

Another problem is that sometimes the compiler is generating
references to tuples with size 1. Of course this type of tuple doesn't
exist and I again end up with unresolved references in the assembling
phase. It seems like these tuples are generated from CaseLib.caseTuple
but I still don't know how to avoid this.

How are you dealing with these issues?

Cheers,
  Krasimir


More information about the Yhc mailing list