Superclass defaults

Simon Peyton-Jones simonpj at microsoft.com
Mon Aug 22 10:10:22 CEST 2011


| > I don't completely understant how does it work. Does client need to enable
| > language extension to get default instances?
| 
| I think that the extension would only be required to *define them*,
| not for them to be generated. The more conservative choice would
| indeed be to require the extension for both, though.

Yes. I've clarified http://hackage.haskell.org/trac/ghc/wiki/DefaultSuperclassInstances to say this.

| > Also proposal cannot fix Functor/Applicative/Monad problem without breaking
| > client code. It requires explicit opt-out but client may define Applicative
| > instance. And unless "hiding" is added it will result in compile error.
| 
| I think the intention (at least as I understand it) is that a
| superclass default is only used to generate an instance if there is
| not already some suitable instance in scope, just like a default
| method is only used if there is not some explicit definition for the
| method in the instance. 

Actually that is not what Conor and I proposed.  See http://hackage.haskell.org/trac/ghc/wiki/DefaultSuperclassInstances.  Under "Variations" we discuss the "silent-opt-out" choice.  But it's bad enough knowing exactly what instances are in scope (given that they are not named), let alone having that control what further instances are or are not generated!  For superclass defaults there is no such ambiguity.

Simon




More information about the Glasgow-haskell-users mailing list