/* Simple parametric implementation */ interface HasOp { fn example(a: 'A, b: 'B) -> ('R, Self); } fn example(a: Int, b: Int) -> (Bool, Int) { return (a + b < 5, 5); } implement HasOp for Int; fn example(a: Array, b: Array<'T>) -> (Int, Array) { return (5, *a); } implement HasOp, Array> for Array; /* Full parametric implementation */ interface Addable { fn add(a: Self, b: Self) -> Self; } fn add(a: Int, b: Int) -> Int { return a + b; } fn add(a: Float, b: Float) -> Float { return a + b; } implement Addable for Int; implement Addable for Float; fn add(a: Array<'T [Addable]>, b: Array<'T [Addable]>) -> Array<'T [Addable]> { return arr<'T>(); } // Parametric implementation implement Addable for Array<'T [Addable]>; let arr_1 = arr(); add(*arr_1, *arr_1); let arr_2 = arr(); add(*arr_2, *arr_2); fn test(v: 'T [Addable]) -> Bool { return true; } test(1); test(2.5); test(*arr_1); test(*arr_2);