-
Notifications
You must be signed in to change notification settings - Fork 0
/
functional.d.tl
145 lines (108 loc) · 5.36 KB
/
functional.d.tl
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
local record module
type producer = function<T>(): T
type consumer = function<T>(T)
type predicate = function<T>(T): boolean
type mapping = function<T, U>(T): U
type reducer = function<T, A>(A, T): A
-- IS stands for "invariant state", as seen in Programming in Lua chapter 7
type vanilla_singlearg_iter = function<IS, T>(IS, T): T
-- FIXME in order to properly support iterators with multiple
-- types per return,
-- https://github.com/teal-language/tl/pull/449
-- needs to be merged
type vanilla_multiarg_iter = function<IS, T>(IS, ...: T): T...
record Iterator<T>
create: function({T}): Iterator<T>
create: function(Iterator<T>): Iterator<T>
counter: function(): Iterator<integer>
from: function<IS>(vanilla_singlearg_iter<IS, T>, IS, T): Iterator<T>
packed_from: function<IS>(vanilla_multiarg_iter<IS, T>, IS, T): Iterator<{T}>
from_coroutine: function(thread): Iterator<any>
range: function(integer, integer, integer): Iterator<integer>
clone: function(Iterator<T>): Iterator<T>
is_complete: function(Iterator<T>): boolean
next: function(Iterator<T>): T
to_array: function(Iterator<T>): {T}
to_coroutine: function(Iterator<T>): thread
filter: function(Iterator<T>, predicate<T>): Iterator<T>
map: function<U>(Iterator<T>, mapping<T, U>): Iterator<U>
reduce: function<A>(Iterator<T>, reducer<T, A>, A): A
foreach: function(Iterator<T>, consumer<T>)
last: function(Iterator<T>): T
take: function(Iterator<T>, integer): Iterator<T>
take_while: function(Iterator<T>, predicate<T>): Iterator<T>
take_until: function(Iterator<T>, predicate<T>): Iterator<T>
take_last: function(Iterator<T>, integer): Iterator<T>
skip: function(Iterator<T>, integer): Iterator<T>
skip_while: function(Iterator<T>, predicate<T>): Iterator<T>
skip_until: function(Iterator<T>, predicate<T>): Iterator<T>
every: function(Iterator<T>, integer): Iterator<T>
any: function(Iterator<T>, predicate<T>): boolean
all: function(Iterator<T>, predicate<T>): boolean
count: function(Iterator<T>, predicate<T>): integer
-- zip cannot be properly implemented until variadic type arguments get stable
packed_zip: function(Iterator<T>, Iterator<T>): Iterator<{T, T}>
packed_zip: function(Iterator<T>, {T}): Iterator<{T, T}>
concat: function(Iterator<T>, Iterator<T>): Iterator<T>
concat: function(Iterator<T>, {T}): Iterator<T>
metamethod __call: function(Iterator<T>): T
end
counter: function(): Iterator<integer>
range: function(integer, integer, integer): Iterator<integer>
iterate: function<T>({T}): Iterator<T>
iterate: function<T>(Iterator<T>): Iterator<T>
filter: function<T>({T}, predicate<T>): Iterator<T>
filter: function<T>(Iterator<T>, predicate<T>): Iterator<T>
map: function<T, U>({T}, mapping<T, U>): Iterator<U>
map: function<T, U>(Iterator<T>, mapping<T, U>): Iterator<U>
reduce: function<T>({T}, reducer<T, T>): T
reduce: function<T>(Iterator<T>, reducer<T, T>): T
reduce: function<T, A>({T}, reducer<T, A>, A): A
reduce: function<T, A>(Iterator<T>, reducer<T, A>, A): A
foreach: function<T>({T}, consumer<T>)
foreach: function<T>(Iterator<T>, consumer<T>)
last: function<T>({T}): T
last: function<T>(Iterator<T>): T
take: function<T>({T}, integer): Iterator<T>
take: function<T>(Iterator<T>, integer): Iterator<T>
skip: function<T>({T}, integer): Iterator<T>
skip: function<T>(Iterator<T>, integer): Iterator<T>
every: function<T>({T}, integer): Iterator<T>
every: function<T>(Iterator<T>, integer): Iterator<T>
any: function<T>({T}, predicate<T>): boolean
any: function<T>(Iterator<T>, predicate<T>): boolean
all: function<T>({T}, predicate<T>): boolean
all: function<T>(Iterator<T>, predicate<T>): boolean
-- Suggestion to change order of these declarations by
-- GitHub user FractalU
to_array: function<T>(Iterator<T>): {T}
to_array: function<T>({T}): {T}
to_coroutine: function<T>({T}): thread
to_coroutine: function<T>(Iterator<T>): thread
-- zip cannot be properly implemented until variadic type arguments get stable
packed_zip: function<T>(Iterator<T>, Iterator<T>): Iterator<{T, T}>
packed_zip: function<T>(Iterator<T>, {T}): Iterator<{T, T}>
packed_zip: function<T>({T}, Iterator<T>): Iterator<{T, T}>
packed_zip: function<T>({T}, {T}): Iterator<{T, T}>
concat: function<T>(Iterator<T>, Iterator<T>): Iterator<T>
concat: function<T>(Iterator<T>, {T}): Iterator<T>
concat: function<T>({T}, Iterator<T>): Iterator<T>
concat: function<T>({T}, {T}): Iterator<T>
negate: function<T>(predicate<T>): predicate<T>
compose: function<T, U, V>(mapping<T, U>, mapping<U, V>): mapping<T, V>
-- FIXME these will get proper support once variadic type arguments are supported
bind: function<T, U>((function(...: T): U), ...: T): (function(...: T): U)
bind_self: function<K, T, U>(table, K, ...: T): (function(...: T): U)
dict: function<K, V>({K: V}): mapping<K, V>
indexer: function<K>(K): (function<V>({K: V}): V)
constant: function<T>(T): producer<T>
lambda: function(string, {string: any}): function
lambda: function({string: any}): function
lambda2: function(string, {string:any}): function
lambda2: function({string:any}): function
clambda: function(string, {string: any}): function
clambda: function({string: any}): function
nop: function()
identity: function<T>(T): T
end
return module