[GHC] #10675: GHC does not check the functional dependency consistency condition correctly

GHC ghc-devs at haskell.org
Thu Sep 13 10:43:57 UTC 2018


#10675: GHC does not check the functional dependency consistency condition
correctly
-------------------------------------+-------------------------------------
        Reporter:  simonpj           |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.10.1
      Resolution:                    |             Keywords:  FunDeps
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 AntC):

 Applying the [ticket:15632#comment:2 suggested rules here]

 * The instances on the O.P. get rejected as inconsistent under the FunDep,
 because

   A) Upon unifying the `a` parameter positions (argument to the FunDep),
      applying the substitution to the `b` position does not give ''equal''
 type for the result.

   B)   i) The FunDep is not full.

      ii) The instance heads overall are in no substitution ordering
 (they're apart).

 If you insist on those instances go either

 {{{#!hs
 instance C Bool [x] [x]                                     -- per O.P.

 instance {-# OVERLAPPABLE #-} C' x a b => C x a b  where    -- catch-all
   op = op'

 class C' x a b  | a -> b  where
   op' :: x -> a -> b
 instance C Char x y => C' Char [x] [Maybe y]                -- per O.P.
 but indirect

 f x = op True [x]                                           -- per O.P.
 -- inferred ===> f :: C Bool [a] [a] => a -> [a]

 }}}

 or

 {{{#!hs
 instance C Char x y => C Char [x] [Maybe y]                 -- per O.P.

 instance {-# OVERLAPPABLE #-} C'' x a b => C x a b  where   -- catch-all
   op = op''

 class C'' x a b  | a -> b  where
   op'' :: x -> a -> b
 instance C'' Bool [x] [x]                                   -- per O.P.
 but indirect

 f x = op True [x]                                           -- per O.P.
 -- inferred ===> f :: a -> [a]

 }}}

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


More information about the ghc-tickets mailing list