On Sep 8, 2006, at 1:32 PM, skaller wrote:

> On Fri, 2006-09-08 at 10:53 -0400, Peter Tanski wrote:
>
> [on typeclasses]
>
>> It isn't impossible and it is not as limited as you might think.
>
> I have no idea how limited it is in practical use, having
> only read how it works, rather than used it!
>
> My comments are simply based on seeing the structure is
> similar to OO, and so must have the same problems,
> but one level up.

Type classes do not suffer the problem of covariance, even one level  
up.  Covariance, defined as a redefinition of a type (or type-class  
restricted operation, such as the arguments or results of functions)  
through an inheritance hierarchy, is not a problem with type classes  
because there is no such thing as redefinition.  Type classes are  
*not* an OO mechanism: you either conform to the rule of the type  
class (by defining one and only one instance definition throughout  
the entire program), or you are not an instance of that class and it  
doesn't bind you.

In Felix, typeclass should have function declarations:

// type classes embody rules; declarations, not definitions
typeclass Eq[T] {       <--suggestion: no '=,' this is not assignment
   add: t * t -> t;
   sub: t * t -> t;     <-- no overriding, no virtual functions
   ..
}

instance Eq[int] {      <--suggestion: no :public typeclass stuff
    fun add: t * t -> t = x + y;
    fun sub: t * t -> t = x - y;
}

// subsets
typeclass Ord[T] <= Eq[T] {  <--suggestion: left-right s <= S
...
}

typeclass OutputIterator[T]
        <= (WriteableIterator[T], ForwardIterator[T]) {
...
}

> Felix has OO style classes (weakly supported).
> With typeclasses we'd get Monads for free .. and that would
> be a considerable asset by itself.

Getting type classes for Felix would be difficult, especially if you  
want multi-parameter type classes.  As a start, you do unfortunately  
have some reading to do.  After that we will have to modify the type  
system to be able to type-check the typeclass.  To start of with  
(basic understanding stuff), read Section 7 of Typing Haskell in  
Haskell, then take your pick of the papers below (selected for  
implementation specific details--there are *lots* of papers for type  
classes).

Type Classes in Haskell (1996)
http://citeseer.ifi.unizh.ch/hall96type.html

Associated Types with Class
http://research.microsoft.com/~simonpj/papers/assoc-types/

Type Checking Multi-Parameter Type Classes (2002)
https://guinness.cs.stevens-tech.edu/~dduggan/Public/Papers/multi.pdf

General Type Class papers
http://www.haskell.org/haskellwiki/Research_papers/ 
Type_systems#Type_classes


-Pete

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to