Primitive types and Prelude shenanigans

William Lee Irwin III
Tue, 13 Feb 2001 16:20:01 -0800

On Mon, 12 Feb 2001, William Lee Irwin III wrote:
>>> I'd also like to see where some of the magic behind the typing of
>>> various other built-in constructs happens, like list comprehensions,
>>> tuples, and derived classes.

On Mon, Feb 12, 2001 at 11:00:02AM +0100, Marcin 'Qrczak' Kowalczyk wrote:
>> Inside the compiler, not in libraries.

On Mon, Feb 12, 2001 at 02:38:25PM -0800, William Lee Irwin III wrote:
> I had in mind looking within the compiler, actually. Where in the
> compiler? It's a big program, it might take me a while to do an
> uninformed search. I've peeked around a little bit and not gotten
> anywhere.

If anyone else is pursuing thoughts along the same lines as I am (and I
have suspicions), TysWiredIn.lhs appears quite relevant to the set of
primitive data types, though there is no obvious connection to the
module issue (PrelBase.Bool vs. Foo.Bool). PrelMods.lhs appears to shed
more light on that issue in particular. $TOP/ghc/compiler/prelude/ was
the gold mine I encountered.

In DsExpr.lhs, I found:
] \subsection[DsExpr-literals]{Literals}
] ...
] We give int/float literals type @Integer@ and @Rational@, respectively.
] The typechecker will (presumably) have put \tr{from{Integer,Rational}s}
] around them.

and following this pointer, I found TcExpr.lhs (lines 213ff) had more
material of interest.

While I can't say I know how to act on these "discoveries" (esp. since
I don't really understand OverloadedIntegral and OverloadedFractional's
treatment(s) yet), perhaps this might be useful to others interested in
ideas along the same lines as mine.

Happy hacking,