[GHC] #16123: QuantifiedConstraints fails to deduce trivial constraint

GHC ghc-devs at haskell.org
Mon Jan 21 21:29:24 UTC 2019


#16123: QuantifiedConstraints fails to deduce trivial constraint
-------------------------------------+-------------------------------------
        Reporter:  eschnett          |                Owner:  (none)
            Type:  bug               |               Status:  closed
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.6.3
      Resolution:  duplicate         |             Keywords:
                                     |  QuantifiedConstraints
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #14680            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 FWIW, I think I've discovered a way to work around this issue after all.
 I've written up the trick in full detail
 [https://ghc.haskell.org/trac/ghc/ticket/14860#comment:23 here], but in
 the particular case of your program, the trick is to redefine `Ok`
 slightly:

 {{{#!hs
   type Ok k :: ObjKind -> Constraint
 }}}

 Once you've done that, you can get the desired superclass for `Functor` if
 you write it like this:

 {{{#!hs
 class ( Category (Dom f), Category (Cod f)
       -- | Prove that this functor maps from its domain to its codomain
       , forall okCodF a. (okCodF ~ Ok (Cod f), Ok (Dom f) a) => okCodF (f
 a)
       ) => Functor f where
 }}}

 If you do this, then the rest of the module typechecks.

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


More information about the ghc-tickets mailing list