[GHC] #11719: Cannot use higher-rank kinds with type families
GHC
ghc-devs at haskell.org
Tue Oct 23 13:48:19 UTC 2018
#11719: Cannot use higher-rank kinds with type families
-------------------------------------+-------------------------------------
Reporter: ocharles | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.8.1
Component: Compiler (Type | Version: 8.0.1-rc2
checker) |
Resolution: | Keywords: TypeInType
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: GHC rejects | Test Case:
valid program | dependent/should_compile/T11719
Blocked By: | Blocking:
Related Tickets: #13913, #14268 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):
* related: #13913 => #13913, #14268
Comment:
I've found a workaround for the original issue in this ticket after much
persistence. The trick is to associate `BaseType` with a type class:
{{{#!hs
class CBaseType (k :: forall a. a ~> Type) (x :: b) where
type BaseType k x :: Type
}}}
Then, define a flexible instance like so, using an explicit `forall` to
give `k` the appropriate higher-rank kind:
{{{#!hs
instance forall b (k :: forall a. a ~> Type) (x :: b). CBaseType k x where
type BaseType k x = (@@) k x
}}}
That's it! Now you can use `BaseType` like you'd expect:
{{{
λ> data ProxySym0 :: forall a. a ~> Type
λ> type instance ProxySym0 @@ x = Proxy x
λ> :kind! BaseType ProxySym0 Bool
BaseType ProxySym0 Bool :: *
= Proxy Bool
λ> :kind! BaseType ProxySym0 Maybe
BaseType ProxySym0 Maybe :: *
= Proxy Maybe
λ> :kind! BaseType ProxySym0 'Just
BaseType ProxySym0 'Just :: *
= Proxy 'Just
}}}
It's a bit gnarly, but this is the best that you can do until #14268 is
implemented.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11719#comment:22>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list