#6134: Incorrect ambiguity error with functional dependencies
---------------------------------------+------------------------------------
 Reporter:  diatchki                   |          Owner:                        
 
     Type:  bug                        |         Status:  new                   
 
 Priority:  normal                     |      Component:  Compiler (Type 
checker)
  Version:  7.4.1                      |       Keywords:                        
 
       Os:  Unknown/Multiple           |   Architecture:  Unknown/Multiple      
 
  Failure:  GHC rejects valid program  |       Testcase:                        
 
Blockedby:                             |       Blocking:                        
 
  Related:                             |  
---------------------------------------+------------------------------------
 GHC reject a program as ambiguous when it is not.  Consider the following
 example:
 {{{
 {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies,
 FlexibleContexts #-}

 class C a b | a -> b where
   f :: a -> b

 test :: (Show a, C Int a) => Bool
 test = show (f (1 :: Int)) == "1"
 }}}
 GHC rejects the program with the following error:
 {{{
     Ambiguous constraint `C Int a'
       At least one of the forall'd type variables mentioned by the
 constraint
       must be reachable from the type after the '=>'
     In the type signature for `test': test :: (Show a, C Int a) => Bool
 }}}

 The only variable, {{{a}}}, is fully determined by the type `Int` via the
 functional dependency on class `C` so there is no ambiguity.

 These sort of errors crop up when we desugar implicit parameters into uses
 of the `IP` class (which has a functional dependency).

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

_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to