
Serge
I'm afraid I don't really follow your proposal in detail, but I think it may be a version of the proposal described here
http://hackage.haskell.org/trac/ghc/wiki/DefaultSuperclassInstances
Perhaps you could see if the design there would meet your goals.
Simon
| -----Original Message-----
| From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell-users-
| bounces@haskell.org] On Behalf Of Serge D. Mechveliani
| Sent: 12 November 2011 10:51
| To: glasgow-haskell-users@haskell.org
| Subject: instance union proposal
|
| Dear Haskell implementors,
|
| I suggest the following small extension to the instance declaration in
| the language. So far -- for Haskell + glasgow-ext.
| I think that they are easy to implement.
| This is the "instance union" proposal.
| It is needed to write shorter several `old' instance declarations.
| This will make programs easier to read.
| It suggests the so-called
| inherited decl and, more general, union decl.
|
| Inherited instance decl proposal
| --------------------------------
|
| Union several instance declarations with the same condition part and such
| that among the conclusion classes there exists some which inherits all
| others.
| Example 1. My program uses the class tower
|
| Field a Picture 1.
| |
| ERing
| |
| CRing a
| |
| Ring a
| / \
| AddGroup a MulSemigroup a
| | |
| AddSemigroup a |
| \ /
| Set a
|
| -- "|" means that the upper inherits from the lower.
| Now, by the application meaning, I need to write
|
| instance (Show a, CRing a) => CRing (Pol a)
| where
| <implement operations of Set>
| <implement operations of AddGroup>
| ...
| <implement operations of CRing>
|
| From the class decls it is clear to the compiler that CRing inherits
| all that is lower on the picture. Therefore, the conditional
| `instance (Show a, CRing a) =>' and 'where'
| is written only once.
| In the existing language, I need to write this conditional 6 times.
|
|
| Union instance decl proposal
| ----------------------------
|
| It is a generalization for inhereted decl.
|
| instances (cond_1, ..., cond_n) -- of the type parameters a_1 ... a_m
| =>
| <typeTuple> (<params>) has {<conclInstList>}
| where
|