Somehow my typeclass problem went away .. actually I accidentally
blew away code and reloaded from svn .. only to find I'd blown
away all my work. So I did it again  and it 'works' now:

///////////////////////////////////////
#import <flx.flxh>

typeclass Eq[t,u] {
  virtual fun xeq: t * u -> 2;
}

instance[v] Eq[v,v] {
  fun xeq:v * v -> 2 = "$1==$2";
}

fun g[with Eq[int,int]] (x:int,y:int)=> xeq(x,y);

print$ g$ 1,2; endl;

fun g2[w with Eq[w,w]] (x:int,y:int)=> xeq(x,y);

print$ g2$ 1,2; endl;
/////////////////////////////////////

[EMAIL PROTECTED]:/work/felix/svn/felix/felix/trunk$ f tc
CLIENT ERROR
Instantiate virtual function(2) xeq<3779>, no instance for
ts=int<700>,int<700>
In ./lib/flx_macros.flxh: line 4, cols 24 to 39
3: macro fun print_line (x) = { fprint (cout,x); Stdout::endl cout; };
4: macro fun print(x) = { fprint (cout,x); };
                          ****************
5:

See also tc.flx: line 4, cols 11 to 30
3: typeclass Eq[t,u] {
4:   virtual fun xeq: t * u -> 2;
             ********************
5: }
//////////////////////////////

The failure is because the instantiator
isn't instantiating yet. The good bit is that this
code passes the type checker.

The registered mapping:

        typeclass function, type variable instances -> instance function

now has type variable instances = v,v: that matches int,int but isn't
equal. 


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

-------------------------------------------------------------------------
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