[GHC] #7100: Loosen requirement for free variables in constraint in class declaration

GHC cvs-ghc at haskell.org
Tue Aug 14 15:54:37 CEST 2012


#7100: Loosen requirement for free variables in constraint in class declaration
-------------------------------+--------------------------------------------
  Reporter:  selinger          |          Owner:                  
      Type:  feature request   |         Status:  closed          
  Priority:  normal            |      Milestone:                  
 Component:  Compiler          |        Version:  7.4.2           
Resolution:  wontfix           |       Keywords:                  
        Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
   Failure:  None/Unknown      |     Difficulty:  Unknown         
  Testcase:                    |      Blockedby:                  
  Blocking:                    |        Related:                  
-------------------------------+--------------------------------------------
Changes (by simonpj):

  * status:  new => closed
  * resolution:  => wontfix


Comment:

 What's wrong with eliminating the fundep in favour of a type function?
 {{{
 class MyClass a where
   type B a
   op :: a -> B a

 instance MyClass Int where
   type B Int = Bool
   op n = n>3
 }}}
 etc.  True, when declaring a class, like your `WPrintF` you may have a bit
 of duplication of calls to the function `F`, but the dependencies are much
 more explicit.

 This really only crops up in class decls.  In an instance decl or function
 type signature you can write
 {{{
 -- Duplicating the (F b):
    f :: (C (F b), D (F b), E (F b)) => b -> b

 -- Without duplication:
   f :: (a ~ F b, C a, D a, E a) => b -> b
 }}}
 Admittedly you can't do that in a class decl, and I suppose one could have
 some special magic to allow
 {{{
   class (a ~ F b, C a, D a, E a) => K b
 }}}
 but we'd have to exclude more general things like
 {{{
   class (F a ~ G b, C a, D a) => K b
 }}}
 I don't think there's enough goodness here to justify the complexity.

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



More information about the Glasgow-haskell-bugs mailing list