#2247: GHC accepts FD violations, unless the conflicing instances are used
-------------------------------------+--------------------------------------
Reporter: claus | Owner:
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Compiler (Type checker) | Version: 6.9
Severity: normal | Resolution: duplicate
Keywords: TF vs FD | Difficulty: Unknown
Testcase: | Architecture: Unknown
Os: Unknown |
-------------------------------------+--------------------------------------
Changes (by simonpj):
* status: new => closed
* difficulty: => Unknown
* resolution: => duplicate
Comment:
I assume you are using some flags?
{{{
ghc -c -XFunctionalDependencies Foo.hs -XMultiParamTypeClasses
Foo.hs:5:1:
Illegal instance declaration for `FD a b'
(All instance types must be of the form (T a1 ... an)
where a1 ... an are distinct type *variables*
Use -XFlexibleInstances if you want to disable this.)
In the instance declaration for `FD a b'
}}}
Adding `-XFlexibleInstances` gives
{{{
bash-3.1$ ghc -c -XFunctionalDependencies Foo.hs -XMultiParamTypeClasses
-XFlexibleInstances
Foo.hs:5:1:
Constraint is no smaller than the instance head
in the constraint: CFD a b
(Use -fallow-undecidable-instances to permit this)
In the instance declaration for `FD a b'
Foo.hs:5:1:
Illegal instance declaration for `FD a b'
(the Coverage Condition fails for one of the functional
dependencies;
Use -fallow-undecidable-instances to permit this)
In the instance declaration for `FD a b'
}}}
In fact to get `Improve` to compile you need
{{{
$gpj -c -XFunctionalDependencies
-XMultiParamTypeClasses
-XFlexibleInstances
-fallow-undecidable-instances
-XFlexibleContexts
Foo.hs
}}}
The offending one is `-fallow-undecidable-instances`, and this ticket is
an excellent example of #1241. Currently saying `-fallow-undecidable-
instances` lifts the coverage condition. I acknowledge that this isn't the
Right Thing in #1241, but it doesn't threaten type soundness (ie programs
will not seg-fault).
So I'm going to close this bug and link to it from #1241. Re-open if I
have misunderstood.
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2247#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs