[GHC] #2853: Defaulting not used enough with type families

GHC trac at galois.com
Mon Dec 8 20:48:48 EST 2008


#2853: Defaulting not used enough with type families
------------------------------+---------------------------------------------
 Reporter:  guest             |          Owner:  chak            
     Type:  bug               |         Status:  new             
 Priority:  normal            |      Milestone:                  
Component:  Compiler          |        Version:  6.10.1          
 Severity:  normal            |     Resolution:                  
 Keywords:                    |       Testcase:                  
       Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
------------------------------+---------------------------------------------
Changes (by chak):

  * owner:  => chak

Comment:

 No, defaulting is not used, but I also '''don't''' think it should be used
 in this example.  The Haskell Report says:
 "[...]an ambiguous type variable, v, is defaultable if:
  * v appears only in constraints of the form C v, where C is a class, and
  * at least one of these classes is a numeric class, (that is, Num or a
 subclass of Num), and
  * all of these classes are defined in the Prelude or a standard library"
 The above code clearly violates the third condition (`C` is not a standard
 class).

 However, I think, we should discuss what would happen for this program:
 {{{
 {-# LANGUAGE TypeFamilies, ExtendedDefaultRules #-}
 module Bug3 where

 class C t where
     type T t

 instance C Integer where
     type T Integer = Integer

 data (Num t) => D t = D (T t)
 instance Show (D a) where show _ = ""
 }}}
 Now, we get (without defaulting): `(Num (T t), Num t) => String`.

 Literally speaking, this still violates the first condition from the
 Haskell Report.  However, you might argue that -in the presence of type
 families- we should generalise the definition of the Report to permit
 classes of the form `C (T v1..vn))` in contexts to which the default rules
 applies.

 SimonPJ, what do you think?

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


More information about the Glasgow-haskell-bugs mailing list