[GHC] #15347: QuantifiedConstraints: Implication constraints with type families don't work

GHC ghc-devs at haskell.org
Thu Jul 26 22:19:56 UTC 2018


#15347: QuantifiedConstraints: Implication constraints with type families don't
work
-------------------------------------+-------------------------------------
        Reporter:  aaronvargo        |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:
      Resolution:                    |  QuantifiedConstraints
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by aaronvargo):

 Replying to [comment:14 simonpj]:

 Yes, sorry!

 > That is, so far I do not understand why floating out type families (a
 straightforward source-to-source transformation that does not change the
 number of class parameters) would sacrifice a major benefit.

 It requires changing the number of class parameters when the quantified
 constraint appears as a superclass. Suppose we would like to write:

 {{{#!hs
 class (forall a. Eq a => Eq (F t a)) => C t where
   type F t :: * -> *
 }}}

 where the type family `F t` in the quantified constraint is independent of
 the quantified `a`. In order to float this type family out, we need to add
 a new parameter to the class, `ft`, and make it equal to `F t`:

 {{{#!hs
 class (ft ~ F t, forall a. Eq a => Eq (ft a)) => C ft t where
   type F t :: * -> *
 }}}

 Furthermore, this parameter can never be instantiated with a type family
 without once again breaking the quantified constraint. E.g. if we write

 {{{#!hs
 class C (F t) t => D t
 }}}

 then the inherited quantified constraint will contain a type family, and
 will no longer work.

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


More information about the ghc-tickets mailing list