1: #line 1829 "./lpsrc/flx_regress.pak"
2:
3:
4:
5: open List;
6:
7: typeclass Str2[T] {
8: virtual fun str2: T->string;
9: }
10:
11: instance Str2[int] {
12: fun str2 (x:int): string => str x;
13: }
14:
15: fun str2[T with Str[T]] (x:list[T]):string =>
16: match x with
17: | Empty[T] => "()"
18: | Cons(?h, ?t) => "(" + (str2 h) + ", " + (str2 t) + ")"
19: endmatch
20: ;
21:
22: fun str2[T with Str2[T]] (x:T) => str2 x;
23:
24: print$ str2 5; endl;
25: print$ str2$ list(1,2,3,4); endl;
26:
1: 5
2: (1, (2, (3, (4, ()))))