[Haskell-cafe] Base classes can be _ELIMINATED_ with interfaces

Shelby Moore shelby at coolpage.com
Sun Nov 1 21:39:08 EST 2009


I was correct before, except I conflated the word "extended" with
"eliminated" in my mind:

http://lambda-the-ultimate.org/node/1277#comment-51723

The most robust solution to Tim Sweeney's problem is to rethink what a
"class" should be:

http://www.haskell.org/haskellwiki/?title=Why_Haskell_matters&oldid=24286#Haskell_vs_OOP

In Haskel, subtyping is done with Module. A "type class" is a polymorphic
(relative to data type) interface, and the polymorphism is strictly
parameterized for the client/consumer of the interface, i.e. the data type
is known to the function that inputs the interface AT COMPILE TIME:

http://www.haskell.org/~pairwise/intro/section2.html#part3

If all the functions/methods of package Engine input exclusively
interfaces (i.e. Engine.IActor), then client package GearsOfWar can create
a new subtype GearsOfWar.Actor which also implements the interface
Engine.IActor (and perhaps even more interfaces).

A problem with virtual (runtime pointer) inheritance is that it hides the
subclass from the compiler.  Polymorphic interfaces are missing from C++
and one can sort of hack an emulation with abstract classes, private
delegates, and templates:

http://lambda-the-ultimate.org/node/1277#comment-51806

In Haskell, parameterized polymorphic interfaces can be inherited, and
this is knowable to the client function at compile time.

Fundamental theorems tell us that any membership rule for a set can not be
an absolute point, thus we should strive for typing and classing
architecture which is the most granular (these are my summaries):

* Russell's Paradox: there is no rule for a set that does not cause it to
contain itself, thus all sets are infinitely recursive.

* Liskov Substition Principle: it is an undecidable problem that subsets
inherit.

* Linsky Referencing: it is undecidable what something is when it is
described or perceived.

* Coase Theorem: there is no external reference point, any such barrier
will fail.

* Godel's Theorem: any formal theory, in which all arithmetic truths can
be proved, is inconsistent.

* 1856 Thermo Law: entire universe (a closed system, i.e. everything)
trends to maximum disorder.


More information about the Haskell-Cafe mailing list