Alternative to type family Any
|Reported by:||mboes||Owned by:|
|Keywords:||TypeFamilies||Cc:||facundo.dominguez, m@…, edsko, ekmett, rrnewton, GregoryCollins|
|Type of failure:||None/Unknown||Test Case:|
|Related Tickets:||9097, 9380||Differential Rev(s):|
Description (last modified by )
In GHC HEAD,
Any is no longer a datatype. There are good reasons for this change, one of which was explained in #9097, the original ticket, and another in #9380. Unfortunately, a casualty of this change is that it is no longer easy to generalize the rank1dynamic package to rank-1 types with type variables of arbitrary kind (not just
*). We submitted a way to do so here, that exploits the fact that
Any has the very magical property of inhabiting *all* kinds, including closed ones.
This works for GHC 7.8, but won't work in HEAD, because we require that there exists a
Typeable instance for
Any, just as there are
Typeable instances for any other type one wishes to have instances for. The reason is that now that
Any is a type family,
Any is no longer a legal instance head.
There are several possible solutions that I see:
- while it's clearly dangerous for the compiler to be inserting the old
Anyduring typechecking from the moment that we have computation in types over closed kinds, we may still want the old
Any, say under a different name, as a backdoor. It wouldn't be used by the compiler during type checking - only by packages such as rank1dynamic. I believe that furthermore, if we restrict the old
Anyto not inhabit closed kinds, then none of the problems cited in the above tickets arise.
- Instead of making the new
Anya type family, keep it a datatype, but ban it from inhabiting closed kinds. I don't know if such an
Anywould be sufficient for the purposes of GHC, however.
- Hardwire a
Typeableinstance for the
Anytype family (not sure if this makes sense).