Changes between Version 16 and Version 17 of DefaultSuperclassInstances


Ignore:
Timestamp:
Aug 15, 2011 8:44:08 AM (4 years ago)
Author:
simonpj
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DefaultSuperclassInstances

    v16 v17  
    2828== Design goals == 
    2929 
    30 A major design goal is this: 
    31  
    32  * '''Design goal 1''': a class C can be re-factored into a class C with a superclass S, without disturbing any clients. 
     30The major design goal is this: 
     31 
     32 * '''Design goal 1: a class C can be re-factored into a class C with a superclass S, without disturbing any clients.''' 
    3333 
    3434The difficulty is that if you start with 
    3535{{{ 
    36 class X a where 
     36class C a where 
    3737   f :: ... 
    3838   g :: ... 
    3939}}} 
    40 and lots of clients write instances of `X` and functions that use it: 
    41 {{{ 
    42 instance X ClientType 
     40and lots of clients write instances of `C` and functions that use it: 
     41{{{ 
     42instance C ClientType 
    4343  f = ...blah... 
    4444  g = ...blah... 
    4545 
    46 foo :: X a => ... 
     46foo :: C a => ... 
    4747foo = ... 
    4848}}} 
    49 Now you want to refactor `X` thus: 
    50 {{{ 
    51 class Y a where 
     49Now you want to refactor `C` thus: 
     50{{{ 
     51class S a where 
    5252  f :: ... 
    53 class Y a => X a where 
     53class S a => C a where 
    5454  g :: ... 
    5555}}} 
    5656Design goal 1 is that this change should not force clients to change their code.  Haskell 98 does not satisfy this goal.  In Haskell 98 the client function `foo` is fine unmodified, but the instance declaration would have to be split into two. 
     57 
     58'''SLPJ''': are there any other design goals? 
    5759 
    5860== The proposal ==