[GHC] #13248: Allow an injective type family RHS to be another injective type family

GHC ghc-devs at haskell.org
Thu Feb 9 04:28:26 UTC 2017


#13248: Allow an injective type family RHS to be another injective type family
-------------------------------------+-------------------------------------
           Reporter:  mniip          |             Owner:
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.0.1
  (Type checker)                     |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Example use case:
 {{{#!hs
 {-# LANGUAGE TypeFamilies, TypeFamilyDependencies, UndecidableInstances
 #-}

 type family Foo a = r | r -> a where
         Foo Int = Char
         Foo Integer = String

 type family Bar a = r | r -> a where
         Bar Char = Double
         Bar String = Float

 type family Baz a = r | r -> a where
         Baz x = Bar (Foo x)
 }}}

 8.0 says:
 {{{
 test.hs:12:9: error:
     • Type family equation violates injectivity annotation.
       RHS of injective type family equation cannot be a type family:
         Baz x = Bar (Foo x) -- Defined at test.hs:12:9
     • In the equations for closed type family ‘Baz’
       In the type family declaration for ‘Baz’
 }}}

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


More information about the ghc-tickets mailing list