On Thu, 2006-10-05 at 13:41 -0700, Erick Tryzelaar wrote:
> skaller wrote:
> >
> > Fixed now. Forgot to instantiate the type variables,
> > it was looking for Str[T] with the T in foo, instead
> > of int.
> 
> Awesome, thanks! Also, felix can almost do one form of 
> typeclasses-in-modules:
> 
> ////////////////////////////////////////////////
> #import <flx.flxh>
> 
> open List;
> 
> typeclass Str[T] {
>   virtual fun str2: T->string;
> }
> 
> module Foo {
>   instance Str[int] {
>     fun str2 (x:int):string => str x;
>   }
> 
>   fun foo[T with Str[T]] (x:T):string => str2 x;
> 
>   fun foo[T with Str[T]] (x:list[T]):string =>
>     match x with
>     | Empty[T] => "()"
>     | Cons(?h, ?t) => "(" + (str2 h) + ", " + (foo t) + ")"
>     endmatch
>   ;
> }
> 
> open Foo;
> 
> print$ Foo::foo 5; endl;
> print$ Foo::foo$ list(1,2,3,4); endl;
> ////////////////////////////////////////////////
> 
> This is erroring out with this:
> 
> ////////////////////////////////////////////////
> CLIENT ERROR
> [lookup_name_in_env]: Name '_inst_Str' not found in environment (depth 2)
> In foo.flx: line 14, cols 18 to 24
> 13:
> 14:   fun foo[T with Str[T]] (x:T):string => str2 x;
>                      *******
> 15:
> ////////////////////////////////////////////////

[EMAIL PROTECTED]:/work/felix/svn/felix/felix/trunk$ f er3
5
(1, (2, (3, (4, ()))))

Try svn update?

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


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to