Re: [GHC] #2247: GHC accepts FD violations, unless the conflicing instances are used

2008-05-03 Thread GHC
#2247: GHC accepts FD violations, unless the conflicing instances are used
-+--
 Reporter:  claus|  Owner:  
 Type:  bug  | Status:  reopened
 Priority:  normal   |  Milestone:  _|_ 
Component:  Compiler (Type checker)  |Version:  6.9 
 Severity:  normal   | Resolution:  
 Keywords:  TF vs FD | Difficulty:  Unknown 
 Testcase:   |   Architecture:  Unknown 
   Os:  Unknown  |  
-+--
Changes (by igloo):

  * milestone:  = _|_

Comment:

 #1241 is _|_, so I guess this should be too

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2247#comment:4
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


Re: [GHC] #2247: GHC accepts FD violations, unless the conflicing instances are used

2008-05-01 Thread GHC
#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
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2247: GHC accepts FD violations, unless the conflicing instances are used

2008-04-30 Thread GHC
#2247: GHC accepts FD violations, unless the conflicing instances are used
+---
Reporter:  claus|Owner: 
Type:  bug  |   Status:  new
Priority:  normal   |Milestone: 
   Component:  Compiler (Type checker)  |  Version:  6.9
Severity:  normal   |   Resolution: 
Keywords:  TF vs FD | Testcase: 
Architecture:  Unknown  |   Os:  Unknown
+---
Comment (by claus):

 here is a slight variation that does not rely on a GHCi session to raise
 the issue
 {{{
 module Improve where

 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' :: FD Bool Bool = Bool
 f' = True

 g' :: FD Bool Char = Bool
 g' = False

 x = f'
 }}}

 {{{
 module Main where
 import Improve

 y = g'

 main = print (x,y)
 }}}

 GHC (6.9.20080217) accepts this, and the executable outputs
 `(True,False)`, even though the first component depends on `instance FD
 Bool Bool` while the second depends on `instance FD Bool Char`.

 Inlining `x` as `f'` is sufficient to raise the expected error message.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2247#comment:1
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