id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	os	architecture	failure	difficulty	testcase	blockedby	blocking	related
2247	GHC accepts FD violations, unless the conflicing instances are used	claus		"consider
{{{
class FD a b | a -> b
instance CFD a b => FD a b

class {- FD a b => -} CFD a b
instance CFD Bool Char
instance CFD Bool Bool

f :: CFD Bool Bool => Bool
f = True

g :: CFD Bool Char => Bool
g = False

f' :: FD Bool Bool => Bool
f' = True

g' :: FD Bool Char => Bool
g' = False
}}}
the class instance for `FD` is odd, because there is no guarantee that instances of `CFD` comply to the FD (and Hugs rejects that instance, unless the superclass constraint for `CFD` is uncommented). as it stands, this code specifies two FD-conflicting instances of class `FD`, but they are implied, not explicit.

GHCi accepts this code, and only complains if the two conflicting instances are used, explicitly, in the same expression:
{{{
*Main> f
True
*Main> g
False
*Main> (f,g)
(True,False)
*Main> f'
True
*Main> g'
False
*Main> (f',g')

<interactive>:1:0:
    Couldn't match expected type `Bool' against inferred type `Char'
    When using functional dependencies to combine
      FD Bool Char, arising from a use of `g'' at <interactive>:1:4-5
      FD Bool Bool, arising from a use of `f'' at <interactive>:1:1-2
    When generalising the type(s) for `it'
*Main> do {let {x=f} ;let {y=g} ; return (x,y) }
(True,False)
*Main> do {let {x=f'} ;let {y=g'} ; return (x,y) }

<interactive>:1:0:
    Couldn't match expected type `Char' against inferred type `Bool'
    When using functional dependencies to combine
      FD Bool Bool, arising from a use of `f'' at <interactive>:1:11-12
      FD Bool Char, arising from a use of `g'' at <interactive>:1:23-24
    When generalising the type(s) for `it'
*Main> let x=f'
*Main> let y=g'
*Main> (x,y)
(True,False)
}}}
so we can have FD-conflicting instances in the same code, even use them in the same GHCi session, as long as they don't meet in the same line..

for further details and questions, see this message:
[http://www.haskell.org/pipermail/haskell-cafe/2008-April/042219.html some questions about type improvement, FDs vs TFs, and Hugs vs GHCi]"	bug	closed	normal	_|_	Compiler (Type checker)	6.9	fixed	TF vs FD		Unknown/Multiple	Unknown/Multiple	None/Unknown	Unknown	typecheck/should_fail/T2247			
