Remove IntRep and WordRep (and maybe AddrRep?)
(Forked from #16964)
WordRep are currently 32-bit on 32-bit systems and
64-bit on 64-bit systems. The problem is
IntRep is still different than
Int32Rep on a 32-bit system (and
Int64Rep on 64-bit), even though they're
represented the same.
The idea is to remove
WordRep so that on a 64-bit system types
Word# would have
Int32Rep on 32-bit).
This simplifies the
PrimRep comparison logic -- e.g. we currently have bugs
when checking coercion safety when coercing a
Int# (which has
IntRep) to a
Int64# (which has
Int64Rep on 64-bit) -- see #16952 (closed). Overall having less
PrimReps should make dealing with them easier.
Similarly, I think we could remove
AddrRep as well -- it'd be
Word64Rep depending on the word size.
PrimRep is exposed to users via
GHC.Types.RuntimeRep, so this is a
user-facing change (but perhaps not in a stable part of the GHC API). E.g. this
main = print (splitApps (typeRepKind (typeRep @Int#)))
will print differently if this proposal is implemented.
I've started working on this -- the main difficulty is we need to pass
DynFlags (or word size) to top-level constants like
wordPrimTyCon, which transitively causes a lot of things to depend on
DynFlags (or word size).