Re: [GHC] #12102: “Constraints in kinds” illegal family application in instance (+ documentation issues?)

GHC ghc-devs at haskell.org
Thu May 4 00:41:43 UTC 2017


#12102: “Constraints in kinds” illegal family application in instance (+
documentation issues?)
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:  TypeInType
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Iceland_jack):

 I think I found a solution for this particular case, using
 `TypeFamilyDependencies`, if we make a restricted code

 {{{#!hs
 data Code = NAT | SYMBOL
 }}}

 with an injective interpretation

 {{{#!hs
 type family
   Interp (a :: Code) = (res :: Type) | res -> a where
   Interp NAT    = Nat
   Interp SYMBOL = Symbol
 }}}

 then you can write

 {{{#!hs
 data T :: forall a. Interp a -> Type where
   MkNat    :: T 42
   MkSymbol :: T "Don't panic!"

 deriving instance Show (T a)
 deriving instance Eq   (T a)
 deriving instance Ord  (T a)
 -- deriving instance Read (T a)
 }}}

 but using any of those methods causes the error in #13643 :) once that
 ticket is created

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12102#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list