instance union proposal

Serge D. Mechveliani mechvel at
Sat Nov 12 11:50:46 CET 2011

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 
Example 1.  My program uses the class tower

                       Field a                 Picture 1.
                       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)
    <implement operations of Set>
    <implement operations of AddGroup>
    <implement operations of CRing>

More information about the Glasgow-haskell-users mailing list