datasort version = V1 | V2
datatype printer (v:version) = PrinterV1 (V1) | PrinterV2 (V2)
typedef printer = [v:version] printer (v)
extern fun {v:version} hello (): void
implement hello<V1> () = println! "hello v1"
implement hello<V2> () = println! "hello v2"
extern fun {v:version} world (printer v): void
implement world<V1> (printer) = println! "world v1"
implement world<V2> (printer) = println! "world v2"
extern fun {v:version} foo (printer v): void
implement {v} foo (printer) =
case+ printer of
| PrinterV1 () => println! "foo v1"
| PrinterV2 () => println! "foo v2"
extern fun bar (printer): void
implement bar (printer) = let
// val [v:version] p = printer: [v:version] printer (v)
in
foo (printer)
end
implement main0 () = let
in
hello<V1> ();
hello<V2> ();
world (PrinterV1);
world (PrinterV2);
foo (PrinterV1);
foo (PrinterV2);
bar (PrinterV1);
bar (PrinterV2);
end