[GHC] #12551: Make type indices take local constraints into account in type instance declaration

GHC ghc-devs at haskell.org
Tue Aug 30 02:28:06 UTC 2016


#12551: Make type indices take local constraints into account in type instance
declaration
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:  TypeFamilies
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):

 Simplified example

 {{{#!hs
 infixr :->
 data Sig x where
   Full  :: a      -> Sig a
   (:->) :: a -> b -> Sig a

 data Exp a where
   Lit :: Int -> Exp (Full Int)
   Add :: Exp (Int :-> Int :-> Full Int)

 class Syntactic a where
   type Rep a
   desugar :: a -> Exp (Full (Rep a))
   sugar   :: Exp (Full (Rep a)) -> a

 instance Syntactic (Exp (Full a)) where
   type Rep (Exp (Full a)) = a
   desugar, sugar :: Exp (Full a) -> Exp (Full a)
   desugar = id
   sugar   = id
 }}}

 ----

 I would like this to compile

 {{{#!hs
 instance a' ~ Full a => Syntactic (Exp a') where
   type Rep (Exp (Full a)) = a
 }}}

 and/or
 {{{#!hs
 instance a' ~ Full a => Syntactic (Exp a') where
   type Rep (Exp a') = a
 }}}

 and/or
 {{{#!hs
 instance a' ~ Full a => Syntactic (Exp a') where
   type Rep (Exp _) = a
 }}}

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


More information about the ghc-tickets mailing list