On Thu, 2006-10-05 at 10:34 -0700, Erick Tryzelaar wrote:

> ///////////////////////////////////
> open List;
> 
> fun foo[T with Str[T]] (x:list[T]):string =>
>   match x with
>   | Empty[T] => "()"
>   | Cons(?h, ?t) => "(" + (str2 h) + ", " + (foo x) + ")"
>   endmatch
> ;
> ///////////////////////////////////

Fixed now. Forgot to instantiate the type variables,
it was looking for Str[T] with the T in foo, instead
of int.


Got worried .. it core dumped .. until I spotted your bug:

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

typeclass Str[T] {
  virtual fun str2: T->string;
}

instance Str[int] {
  fun str2 (x:int):string => str x;
}

open List;

fun foo[T with Str[T]] (x:list[T]):string =>
  match x with
  | Empty[T] => "()"
  | Cons(?h, ?t) => "(" + (str2 h) + ", " + (foo t) + ")"
// ----------------------------------------------^
  endmatch
;

val x = list(1,2);
print$ foo x; endl;
///////////////////////////////////////////



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