[Haskell-cafe] Thoughts about redesigning "Num" type class
Oleg
oleg at okmij.org
Wed Sep 9 10:32:49 UTC 2015
Alexey Muranov wrote:
> My, maybe naive, impression is that there should always be one class per
> operation, as this is obviously the most flexible approach. Then maybe some
> classes can be grouped together by introducing other classes.
Truly what goes around comes around. The ``less ad hoc'' overloading
which we now associate with type classes was first proposed (and even
implemented!) by Stefan Kaes, a couple of years before the type
classes. Kaes so-called parametric overloading may be regarded as an
implementation of type classes with only one method.
http://okmij.org/ftp/Computation/typeclass.html#Kaes
Incidentally, Kaes' system included not only `local instances' but
also `local classes'.
Likewise, 'Haskell with only one type class',
http://okmij.org/ftp/Haskell/TypeClass.html#Haskell1
deals first with one-method classes. Type classes like Num are then
regarded as convenient collections, as bundles of previously defined
methods. Naturally, the same method, like (+), can be a part of
several bundles, not necessarily related otherwise. Incidentally, The
`Haskell with only one type class' required NO extensions, even back
in 2007, when it was first proposed.
More information about the Haskell-Cafe
mailing list