192 lines
9.3 KiB
Text
192 lines
9.3 KiB
Text
=== tests/cases/compiler/genericTypeParameterEquivalence2.ts ===
|
|
// compose :: (b->c) -> (a->b) -> (a->c)
|
|
function compose<A, B, C>(f: (b: B) => C, g: (a:A) => B): (a:A) => C {
|
|
>compose : Symbol(compose, Decl(genericTypeParameterEquivalence2.ts, 0, 0))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 1, 17))
|
|
>B : Symbol(B, Decl(genericTypeParameterEquivalence2.ts, 1, 19))
|
|
>C : Symbol(C, Decl(genericTypeParameterEquivalence2.ts, 1, 22))
|
|
>f : Symbol(f, Decl(genericTypeParameterEquivalence2.ts, 1, 26))
|
|
>b : Symbol(b, Decl(genericTypeParameterEquivalence2.ts, 1, 30))
|
|
>B : Symbol(B, Decl(genericTypeParameterEquivalence2.ts, 1, 19))
|
|
>C : Symbol(C, Decl(genericTypeParameterEquivalence2.ts, 1, 22))
|
|
>g : Symbol(g, Decl(genericTypeParameterEquivalence2.ts, 1, 41))
|
|
>a : Symbol(a, Decl(genericTypeParameterEquivalence2.ts, 1, 46))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 1, 17))
|
|
>B : Symbol(B, Decl(genericTypeParameterEquivalence2.ts, 1, 19))
|
|
>a : Symbol(a, Decl(genericTypeParameterEquivalence2.ts, 1, 59))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 1, 17))
|
|
>C : Symbol(C, Decl(genericTypeParameterEquivalence2.ts, 1, 22))
|
|
|
|
return function (a:A) : C {
|
|
>a : Symbol(a, Decl(genericTypeParameterEquivalence2.ts, 2, 21))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 1, 17))
|
|
>C : Symbol(C, Decl(genericTypeParameterEquivalence2.ts, 1, 22))
|
|
|
|
return f(g.apply(null, a));
|
|
>f : Symbol(f, Decl(genericTypeParameterEquivalence2.ts, 1, 26))
|
|
>g.apply : Symbol(Function.apply, Decl(lib.d.ts, 228, 20))
|
|
>g : Symbol(g, Decl(genericTypeParameterEquivalence2.ts, 1, 41))
|
|
>apply : Symbol(Function.apply, Decl(lib.d.ts, 228, 20))
|
|
>a : Symbol(a, Decl(genericTypeParameterEquivalence2.ts, 2, 21))
|
|
|
|
};
|
|
}
|
|
|
|
// forEach :: [a] -> (a -> ()) -> ()
|
|
function forEach<A>(list: A[], f: (a: A, n?: number) => void ): void {
|
|
>forEach : Symbol(forEach, Decl(genericTypeParameterEquivalence2.ts, 5, 1))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 8, 17))
|
|
>list : Symbol(list, Decl(genericTypeParameterEquivalence2.ts, 8, 20))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 8, 17))
|
|
>f : Symbol(f, Decl(genericTypeParameterEquivalence2.ts, 8, 30))
|
|
>a : Symbol(a, Decl(genericTypeParameterEquivalence2.ts, 8, 35))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 8, 17))
|
|
>n : Symbol(n, Decl(genericTypeParameterEquivalence2.ts, 8, 40))
|
|
|
|
for (var i = 0; i < list.length; ++i) {
|
|
>i : Symbol(i, Decl(genericTypeParameterEquivalence2.ts, 9, 12))
|
|
>i : Symbol(i, Decl(genericTypeParameterEquivalence2.ts, 9, 12))
|
|
>list.length : Symbol(Array.length, Decl(lib.d.ts, 1007, 20))
|
|
>list : Symbol(list, Decl(genericTypeParameterEquivalence2.ts, 8, 20))
|
|
>length : Symbol(Array.length, Decl(lib.d.ts, 1007, 20))
|
|
>i : Symbol(i, Decl(genericTypeParameterEquivalence2.ts, 9, 12))
|
|
|
|
f(list[i], i);
|
|
>f : Symbol(f, Decl(genericTypeParameterEquivalence2.ts, 8, 30))
|
|
>list : Symbol(list, Decl(genericTypeParameterEquivalence2.ts, 8, 20))
|
|
>i : Symbol(i, Decl(genericTypeParameterEquivalence2.ts, 9, 12))
|
|
>i : Symbol(i, Decl(genericTypeParameterEquivalence2.ts, 9, 12))
|
|
}
|
|
}
|
|
|
|
// filter :: (a->bool) -> [a] -> [a]
|
|
function filter<A>(f: (a: A) => boolean, ar: A[]): A[] {
|
|
>filter : Symbol(filter, Decl(genericTypeParameterEquivalence2.ts, 12, 1))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 15, 16))
|
|
>f : Symbol(f, Decl(genericTypeParameterEquivalence2.ts, 15, 19))
|
|
>a : Symbol(a, Decl(genericTypeParameterEquivalence2.ts, 15, 23))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 15, 16))
|
|
>ar : Symbol(ar, Decl(genericTypeParameterEquivalence2.ts, 15, 40))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 15, 16))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 15, 16))
|
|
|
|
var ret = [];
|
|
>ret : Symbol(ret, Decl(genericTypeParameterEquivalence2.ts, 16, 7))
|
|
|
|
forEach(ar, (el) => {
|
|
>forEach : Symbol(forEach, Decl(genericTypeParameterEquivalence2.ts, 5, 1))
|
|
>ar : Symbol(ar, Decl(genericTypeParameterEquivalence2.ts, 15, 40))
|
|
>el : Symbol(el, Decl(genericTypeParameterEquivalence2.ts, 17, 17))
|
|
|
|
if (f(el)) {
|
|
>f : Symbol(f, Decl(genericTypeParameterEquivalence2.ts, 15, 19))
|
|
>el : Symbol(el, Decl(genericTypeParameterEquivalence2.ts, 17, 17))
|
|
|
|
ret.push(el);
|
|
>ret.push : Symbol(Array.push, Decl(lib.d.ts, 1016, 29))
|
|
>ret : Symbol(ret, Decl(genericTypeParameterEquivalence2.ts, 16, 7))
|
|
>push : Symbol(Array.push, Decl(lib.d.ts, 1016, 29))
|
|
>el : Symbol(el, Decl(genericTypeParameterEquivalence2.ts, 17, 17))
|
|
}
|
|
} );
|
|
|
|
return ret;
|
|
>ret : Symbol(ret, Decl(genericTypeParameterEquivalence2.ts, 16, 7))
|
|
}
|
|
|
|
// length :: [a] -> Num
|
|
function length2<A>(ar: A[]): number {
|
|
>length2 : Symbol(length2, Decl(genericTypeParameterEquivalence2.ts, 24, 1))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 27, 17))
|
|
>ar : Symbol(ar, Decl(genericTypeParameterEquivalence2.ts, 27, 20))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 27, 17))
|
|
|
|
return ar.length;
|
|
>ar.length : Symbol(Array.length, Decl(lib.d.ts, 1007, 20))
|
|
>ar : Symbol(ar, Decl(genericTypeParameterEquivalence2.ts, 27, 20))
|
|
>length : Symbol(Array.length, Decl(lib.d.ts, 1007, 20))
|
|
}
|
|
|
|
// curry1 :: ((a,b)->c) -> (a->(b->c))
|
|
function curry1<A, B, C>(f: (a: A, b: B) => C): (ax: A) => (bx: B) => C {
|
|
>curry1 : Symbol(curry1, Decl(genericTypeParameterEquivalence2.ts, 29, 1))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 32, 16))
|
|
>B : Symbol(B, Decl(genericTypeParameterEquivalence2.ts, 32, 18))
|
|
>C : Symbol(C, Decl(genericTypeParameterEquivalence2.ts, 32, 21))
|
|
>f : Symbol(f, Decl(genericTypeParameterEquivalence2.ts, 32, 25))
|
|
>a : Symbol(a, Decl(genericTypeParameterEquivalence2.ts, 32, 29))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 32, 16))
|
|
>b : Symbol(b, Decl(genericTypeParameterEquivalence2.ts, 32, 34))
|
|
>B : Symbol(B, Decl(genericTypeParameterEquivalence2.ts, 32, 18))
|
|
>C : Symbol(C, Decl(genericTypeParameterEquivalence2.ts, 32, 21))
|
|
>ax : Symbol(ax, Decl(genericTypeParameterEquivalence2.ts, 32, 49))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 32, 16))
|
|
>bx : Symbol(bx, Decl(genericTypeParameterEquivalence2.ts, 32, 60))
|
|
>B : Symbol(B, Decl(genericTypeParameterEquivalence2.ts, 32, 18))
|
|
>C : Symbol(C, Decl(genericTypeParameterEquivalence2.ts, 32, 21))
|
|
|
|
return function (ay: A) {
|
|
>ay : Symbol(ay, Decl(genericTypeParameterEquivalence2.ts, 33, 21))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 32, 16))
|
|
|
|
return function (by: B) {
|
|
>by : Symbol(by, Decl(genericTypeParameterEquivalence2.ts, 34, 25))
|
|
>B : Symbol(B, Decl(genericTypeParameterEquivalence2.ts, 32, 18))
|
|
|
|
return f(ay, by);
|
|
>f : Symbol(f, Decl(genericTypeParameterEquivalence2.ts, 32, 25))
|
|
>ay : Symbol(ay, Decl(genericTypeParameterEquivalence2.ts, 33, 21))
|
|
>by : Symbol(by, Decl(genericTypeParameterEquivalence2.ts, 34, 25))
|
|
|
|
};
|
|
};
|
|
}
|
|
|
|
var cfilter = curry1(filter);
|
|
>cfilter : Symbol(cfilter, Decl(genericTypeParameterEquivalence2.ts, 40, 3))
|
|
>curry1 : Symbol(curry1, Decl(genericTypeParameterEquivalence2.ts, 29, 1))
|
|
>filter : Symbol(filter, Decl(genericTypeParameterEquivalence2.ts, 12, 1))
|
|
|
|
// compose :: (b->c) -> (a->b) -> (a->c)
|
|
// length :: [a] -> Num
|
|
// cfilter :: {} -> {} -> [{}]
|
|
// pred :: a -> Bool
|
|
// cfilter(pred) :: {} -> [{}]
|
|
// length2 :: [a] -> Num
|
|
// countWhere :: (a -> Bool) -> [a] -> Num
|
|
|
|
function countWhere_1<A>(pred: (a: A) => boolean): (a: A[]) => number {
|
|
>countWhere_1 : Symbol(countWhere_1, Decl(genericTypeParameterEquivalence2.ts, 40, 29))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 50, 22))
|
|
>pred : Symbol(pred, Decl(genericTypeParameterEquivalence2.ts, 50, 25))
|
|
>a : Symbol(a, Decl(genericTypeParameterEquivalence2.ts, 50, 32))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 50, 22))
|
|
>a : Symbol(a, Decl(genericTypeParameterEquivalence2.ts, 50, 52))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 50, 22))
|
|
|
|
return compose(length2, cfilter(pred));
|
|
>compose : Symbol(compose, Decl(genericTypeParameterEquivalence2.ts, 0, 0))
|
|
>length2 : Symbol(length2, Decl(genericTypeParameterEquivalence2.ts, 24, 1))
|
|
>cfilter : Symbol(cfilter, Decl(genericTypeParameterEquivalence2.ts, 40, 3))
|
|
>pred : Symbol(pred, Decl(genericTypeParameterEquivalence2.ts, 50, 25))
|
|
}
|
|
|
|
function countWhere_2<A>(pred: (a: A) => boolean): (a: A[]) => number {
|
|
>countWhere_2 : Symbol(countWhere_2, Decl(genericTypeParameterEquivalence2.ts, 52, 1))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 54, 22))
|
|
>pred : Symbol(pred, Decl(genericTypeParameterEquivalence2.ts, 54, 25))
|
|
>a : Symbol(a, Decl(genericTypeParameterEquivalence2.ts, 54, 32))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 54, 22))
|
|
>a : Symbol(a, Decl(genericTypeParameterEquivalence2.ts, 54, 52))
|
|
>A : Symbol(A, Decl(genericTypeParameterEquivalence2.ts, 54, 22))
|
|
|
|
var where = cfilter(pred);
|
|
>where : Symbol(where, Decl(genericTypeParameterEquivalence2.ts, 55, 7))
|
|
>cfilter : Symbol(cfilter, Decl(genericTypeParameterEquivalence2.ts, 40, 3))
|
|
>pred : Symbol(pred, Decl(genericTypeParameterEquivalence2.ts, 54, 25))
|
|
|
|
return compose(length2, where);
|
|
>compose : Symbol(compose, Decl(genericTypeParameterEquivalence2.ts, 0, 0))
|
|
>length2 : Symbol(length2, Decl(genericTypeParameterEquivalence2.ts, 24, 1))
|
|
>where : Symbol(where, Decl(genericTypeParameterEquivalence2.ts, 55, 7))
|
|
}
|