deriving...

Simon Peyton-Jones simonpj at microsoft.com
Wed Oct 20 04:01:32 EDT 2004


| Why not even simply
| 
| instance Typeable (T a)
| 
| In other words, derivable classes define default
| implementations for all their methods.

But that has an existing meaning!  It means "use the default methods for
all methods of the class".  Which is not the same as "derive all
methods".

It'd have to be
  instance Typeable (T a) deriving
or
  derive instance Typeable (T a)
Something to clearly signal the magic. 

The trouble is, as you mention, that instance decls usually have a
context.  I'd be quite happy to require a context in these derived
instances too, so you have to write
  derive instance Typeable a => Typeable (T a)
Then it looks more like a regular instance decl.

Claus asks:

| still, will non-variable parameters be permitted, and do we know
| what that means?

I was thinking of using exactly the same rules as now; type variables
only.

Simon


More information about the Glasgow-haskell-users mailing list