On Mon, 2007-10-01 at 22:34 -0700, Erick Tryzelaar wrote:
> On 10/1/07, skaller <[EMAIL PROTECTED]> wrote:

> Yes I'm aware of that problem and it's great to hear you might have a
> solution to it. 

Well, this works now:

/////////////////////////////////////////////
instance[T,U] Str[T * U] {
  fun str (x:T, y:U)=> str x + ", " + str y;
}
instance Str[unit] {
  fun str() => "";
}

println$ str (1,(2,("3",())));
////////////////////////////////////////////////
$ f s2
1, 2, 3, 
//////////////////////////////////////////////////

Unfortunately this:

instance[T] Str[T*unit] {
  fun str( x:T,y:unit) => str x;
}

gives:

Unimplemented: Multiple matching instances for typeclass virtual
instance
str<1898>[string<2133> * unit]
Function 4818 instance parent 4814
SYSTEM FAILURE
Woops can't find instance 4814

Haskell doesn't allow this either, although I think GHC does.
The algorithm of choice is the same one used for overloading:
allow overlapping instances and use the most specialised one.



-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to