[GHC] #14010: UndecidableSuperClasses - Could not deduce (Category d)

GHC ghc-devs at haskell.org
Mon Jul 24 15:00:40 UTC 2017


#14010: UndecidableSuperClasses - Could not deduce (Category d)
-------------------------------------+-------------------------------------
        Reporter:  int-index         |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:
                                     |  UndecidableSuperClasses
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 simonpj):

 GHC's error message looks absolutely right to me.

 Writing in the kinds we have
 {{{
 Functor :: forall c d. (c -> d) -> Constraint
 OnSnd   :: forall c d. ((c,d) -> *) -> c -> d -> *

 class (Category c, Category d)
     => MyFunctor @c @d (f :: c -> d) where

 instance MyFunctor @(c,d) @* (f2 :: (c, d) -> *)
       => MyFunctor @d     @* (OnSnd @c @d f2 (a::c)) where
 }}}
 From the instance declaration we are obliged to generate superclasses for
 `MyFunctor @d @* (OnSnd @c @d f2 (a::c))`, namely
 {{{
 [W] Category d
 [W] Category *
 }}}
 The latter is no problem, but `Category d` is.   What do we have available
 to prove it?   Just the instance context
 {{{
 [G] MyFunctor @(c,d) @* (f2 :: (c,d) -> *)
 }}}
 If we have that given, then we have its superclasses given:
 {{{
 [G] Category (c,d)
 [G] Category *
 }}}
 Can we prove `Category d` given `Category (c,d)`?  No we cannot.  And that
 is just what GHC says.  Here it is with `-fprint-explicit-kinds`:
 {{{
 T14010.hs:45:10: error:
     * Could not deduce (Category d)
         arising from the superclasses of an instance declaration
       from the context: MyFunctor (c, d) * f2
         bound by the instance declaration at T14010.hs:(45,10)-(46,31)
 }}}
 So I claim this is a non-bug.

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


More information about the ghc-tickets mailing list