Remove IntRep and WordRep (and maybe AddrRep?)
(Forked from #16964 (closed))
The PrimReps IntRep and 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 IntRep and WordRep so that on a 64-bit system types
like Int# and Word# would have Int64Rep (and 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 Word32Rep or
Word64Rep depending on the word size.
(Doing this is one way to fix #16952 (closed) and unblock the !1381 (closed) -- which fixes release-blocking #16893 (closed))
Note that 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
program
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 intPrimTyCon and
wordPrimTyCon, which transitively causes a lot of things to depend on
DynFlags (or word size).