File: genericTypeParameterEquivalence2.types

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (177 lines) | stat: -rw-r--r-- 4,584 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
=== 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 : <A, B, C>(f: (b: B) => C, g: (a: A) => B) => (a: A) => C
>f : (b: B) => C
>b : B
>g : (a: A) => B
>a : A
>a : A

    return function (a:A) : C {
>function (a:A) : C {        return f(g.apply(null, a));    } : (a: A) => C
>a : A

        return f(g.apply(null, a));
>f(g.apply(null, a)) : C
>f : (b: B) => C
>g.apply(null, a) : any
>g.apply : (this: Function, thisArg: any, argArray?: any) => any
>g : (a: A) => B
>apply : (this: Function, thisArg: any, argArray?: any) => any
>null : null
>a : A

    };
}

// forEach :: [a] -> (a -> ()) -> ()
function forEach<A>(list: A[], f: (a: A, n?: number) => void ): void {
>forEach : <A>(list: A[], f: (a: A, n?: number) => void) => void
>list : A[]
>f : (a: A, n?: number) => void
>a : A
>n : number

    for (var i = 0; i < list.length; ++i) {
>i : number
>0 : 0
>i < list.length : boolean
>i : number
>list.length : number
>list : A[]
>length : number
>++i : number
>i : number

        f(list[i], i);
>f(list[i], i) : void
>f : (a: A, n?: number) => void
>list[i] : A
>list : A[]
>i : number
>i : number
    }
}

// filter :: (a->bool) -> [a] -> [a]
function filter<A>(f: (a: A) => boolean, ar: A[]): A[] {
>filter : <A>(f: (a: A) => boolean, ar: A[]) => A[]
>f : (a: A) => boolean
>a : A
>ar : A[]

    var ret = [];
>ret : any[]
>[] : undefined[]

    forEach(ar, (el) => {
>forEach(ar, (el) => {        if (f(el)) {            ret.push(el);        }    } ) : void
>forEach : <A>(list: A[], f: (a: A, n?: number) => void) => void
>ar : A[]
>(el) => {        if (f(el)) {            ret.push(el);        }    } : (el: A) => void
>el : A

        if (f(el)) {
>f(el) : boolean
>f : (a: A) => boolean
>el : A

            ret.push(el);
>ret.push(el) : number
>ret.push : (...items: any[]) => number
>ret : any[]
>push : (...items: any[]) => number
>el : A
        }
    } );

    return ret;
>ret : any[]
}

// length :: [a] -> Num
function length2<A>(ar: A[]): number {
>length2 : <A>(ar: A[]) => number
>ar : A[]

    return ar.length;
>ar.length : number
>ar : A[]
>length : number
}

// curry1 :: ((a,b)->c) -> (a->(b->c))
function curry1<A, B, C>(f: (a: A, b: B) => C): (ax: A) => (bx: B) => C {
>curry1 : <A, B, C>(f: (a: A, b: B) => C) => (ax: A) => (bx: B) => C
>f : (a: A, b: B) => C
>a : A
>b : B
>ax : A
>bx : B

    return function (ay: A) {
>function (ay: A) {        return function (by: B) {            return f(ay, by);        };    } : (ay: A) => (by: B) => C
>ay : A

        return function (by: B) {
>function (by: B) {            return f(ay, by);        } : (by: B) => C
>by : B

            return f(ay, by);
>f(ay, by) : C
>f : (a: A, b: B) => C
>ay : A
>by : B

        };
    };
}

var cfilter = curry1(filter);
>cfilter : <A>(ax: (a: A) => boolean) => (bx: A[]) => A[]
>curry1(filter) : <A>(ax: (a: A) => boolean) => (bx: A[]) => A[]
>curry1 : <A, B, C>(f: (a: A, b: B) => C) => (ax: A) => (bx: B) => C
>filter : <A>(f: (a: A) => boolean, ar: A[]) => A[]

// 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 : <A>(pred: (a: A) => boolean) => (a: A[]) => number
>pred : (a: A) => boolean
>a : A
>a : A[]

    return compose(length2, cfilter(pred));
>compose(length2, cfilter(pred)) : (a: A[]) => number
>compose : <A, B, C>(f: (b: B) => C, g: (a: A) => B) => (a: A) => C
>length2 : <A>(ar: A[]) => number
>cfilter(pred) : (bx: A[]) => A[]
>cfilter : <A>(ax: (a: A) => boolean) => (bx: A[]) => A[]
>pred : (a: A) => boolean
}

function countWhere_2<A>(pred: (a: A) => boolean): (a: A[]) => number {
>countWhere_2 : <A>(pred: (a: A) => boolean) => (a: A[]) => number
>pred : (a: A) => boolean
>a : A
>a : A[]

    var where = cfilter(pred);
>where : (bx: A[]) => A[]
>cfilter(pred) : (bx: A[]) => A[]
>cfilter : <A>(ax: (a: A) => boolean) => (bx: A[]) => A[]
>pred : (a: A) => boolean

    return compose(length2, where);
>compose(length2, where) : (a: A[]) => number
>compose : <A, B, C>(f: (b: B) => C, g: (a: A) => B) => (a: A) => C
>length2 : <A>(ar: A[]) => number
>where : (bx: A[]) => A[]
}