[GHC] #9858: Typeable instances should be kind-aware
GHC
ghc-devs at haskell.org
Thu Feb 5 00:42:47 UTC 2015
#9858: Typeable instances should be kind-aware
-------------------------------------+-------------------------------------
Reporter: dreixel | Owner: dreixel
Type: bug | Status: new
Priority: highest | Milestone: 7.10.1
Component: Compiler | Version: 7.9
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: None/Unknown | Unknown/Multiple
Blocked By: | Test Case:
Related Tickets: | Blocking:
| Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by oerjan):
I was going to say that this need to do kind decomposition when inferring
`Typeable` instances is why this cannot be done just with standalone
instances, and you need a solver.
In fact the last time I gave up on my [comment:33 attempt] to express this
in source code, it was because I realized that the fundamental instance
{{{
instance (Typeable a, Typeable b) => Typeable (a b)
}}}
already needs such decomposition to be written.
But today I had an epiphany: This ''can'' be expressed with current types,
although with the annoying need to wrap kinds in proxies:
{{{
-- Ideally k itself should be the class argument, but that is not yet
-- supported. I think this is what makes UndecidableInstances
-- necessary for defining instances. Fortunately the instances seem to be
-- usable without it.
class (KindableParts a, a ~ Proxy) => Kindable (a :: k -> *) where
type KindableParts a :: Constraint
kindRep :: KindRep a
class Kindable (Proxy :: k -> *) => Typeable (a :: k) where
typeRep :: proxy a -> TypeRep
}}}
I wrote up enough of a mock implementation to make the last test case
above work with this.
The code is a bit long, so I put it
[http://oerjan.nvg.org/haskell/TypeableDesign/ on my website].
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9858#comment:48>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list