Remove the special case for tagToEnum# in the code generator?
The only remaining primop (aside from unsafeCoerce#
and seq
) that produces an enumeration type is tagToEnum#
. There is some magic in the code generator to make garbage collection relating to this work as it has historically. We want to get rid of the special case. Simply removing it altogether actually does seem to work (in that CI doesn't complain, see D3980, although I don't yet know why), but the code we generate likely isn't quite the same. The challenge here is that (despite what I thought earlier) we definitely can end up in code generation, under certain circumstances, with
case tagToEnum# @t x of
...
How does this happen? After all, in caseRules
we carefully remove every case on tagToEnum#
and dataToTag#
applications! The trouble comes when CorePrep puts everything in A-normal form. Strict function applications are transformed into case
forms, so
f (tagToEnum# x)
will become
case tagToEnum# x of y
DEFAULT -> f y
Suddenly we have that ugly case! Hmph.