[GHC] #9429: Alternative to type family Any
GHC
ghc-devs at haskell.org
Sun Aug 10 11:07:00 UTC 2014
#9429: Alternative to type family Any
-------------------------------------+-------------------------------------
Reporter: mboes | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.9
Keywords: | Operating System:
Architecture: Unknown/Multiple | Unknown/Multiple
Difficulty: Unknown | Type of failure:
Blocked By: | None/Unknown
Related Tickets: 9097, 9380 | Test Case:
| Blocking:
| Differential Revisions:
-------------------------------------+-------------------------------------
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
[https://hackage.haskell.org/package/rank1dynamic|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
`Any` during 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 `Any` to not inhabit closed kinds,
then none of the problems cited in the above tickets arise.
* Instead of making the new `Any` a type family, keep it a datatype, but
ban it from inhabiting closed kinds. I don't know if such an `Any` would
be sufficient for the purposes of GHC, however.
* Hardwire a `Typeable` instance for the `Any` type family (not sure if
this makes sense).
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9429>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list