UNPKG

22.9 kBTypeScriptView Raw
1// Type definitions for prelude.ls 1.1.1
2// Project: http://www.preludels.com
3// Definitions by: Aya Morisawa <https://github.com/AyaMorisawa>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6// Change [0]: 2015/06/14 - Marcelo Camargo <https://github.com/haskellcamargo>
7
8
9declare namespace PreludeLS {
10 export function id<A>(x: A): A;
11 export function isType<A>(type: string): (x: A) => boolean;
12 export function isType<A>(type: string, x: A): boolean;
13 export function replicate<A>(n: number): (x: A) => A[];
14 export function replicate<A>(n: number, x: A): A[];
15
16
17 // List
18
19 export function each<A>(f: (x: A) => void): (xs: A[]) => A[];
20 export function each<A>(f: (x: A) => void, xs: A[]): A[];
21 export function map<A, B>(f: (x: A) => B): (xs: A[]) => B[];
22 export function map<A, B>(f: (x: A) => B, xs: A[]): B[];
23 export function compact<A>(xs: A[]): A[];
24 export function filter<A>(f: (x: A) => boolean): (xs: A[]) => A[];
25 export function filter<A>(f: (x: A) => boolean, xs: A[]): A[];
26 export function reject<A>(f: (x: A) => boolean): (xs: A[]) => A[];
27 export function reject<A>(f: (x: A) => boolean, xs: A[]): A[];
28 export function partition<A>(f: (x: A) => Boolean): (xs: A[]) => [A[], A[]];
29 export function partition<A>(f: (x: A) => Boolean, xs: A[]): [A[], A[]];
30 export function find<A>(f: (x: A) => Boolean): (xs: A[]) => A;
31 export function find<A>(f: (x: A) => Boolean, xs: A[]): A;
32 export function head<A>(xs: A[]): A;
33 export function tail<A>(xs: A[]): A[];
34 export function last<A>(xs: A[]): A;
35 export function initial<A>(xs: A[]): A[];
36 export function empty<A>(xs: A[]): boolean;
37 export function reverse<A>(xs: A[]): A[];
38 export function unique<A>(xs: A[]): A[];
39 export function uniqueBy<A, B>(f: (x: A) => B): (xs: A[]) => A[];
40 export function uniqueBy<A, B>(f: (x: A) => B, xs: A[]): A[];
41 export function fold<A, B>(f: (x: A) => (y: B) => A): (memo: A) => (xs: B[]) => A;
42 export function fold<A, B>(f: (x: A) => (y: B) => A, memo: A): (xs: B[]) => A;
43 export function fold<A, B>(f: (x: A) => (y: B) => A, memo: A, xs: B[]): A;
44 export function foldl<A, B>(f: (x: A) => (y: B) => A): (memo: A) => (xs: B[]) => A;
45 export function foldl<A, B>(f: (x: A) => (y: B) => A, memo: A): (xs: B[]) => A;
46 export function foldl<A, B>(f: (x: A) => (y: B) => A, memo: A, xs: B[]): A;
47 export function fold1<A>(f: (x: A) => (y: A) => A): (xs: A[]) => A;
48 export function fold1<A>(f: (x: A) => (y: A) => A, xs: A[]): A;
49 export function foldl1<A>(f: (x: A) => (y: A) => A): (xs: A[]) => A;
50 export function foldl1<A>(f: (x: A) => (y: A) => A, xs: A[]): A;
51 export function foldr<A, B>(f: (x: A) => (y: B) => B): (memo: B) => (xs: A[]) => B;
52 export function foldr<A, B>(f: (x: A) => (y: B) => B, memo: B): (xs: A[]) => B;
53 export function foldr<A, B>(f: (x: A) => (y: B) => B, memo: B, xs: A[]): B;
54 export function foldr1<A>(f: (x: A) => (y: A) => A): (xs: A[]) => A;
55 export function foldr1<A>(f: (x: A) => (y: A) => A, xs: A[]): A;
56 export function unfoldr<A, B>(f: (x: B) => ([A, B] | void)): (x: B) => A[];
57 export function unfoldr<A, B>(f: (x: B) => ([A, B] | void), x: B): A[];
58 export function concat<A>(xss: A[][]): A[];
59 export function concatMap<A, B>(f: (x: A) => B[]): (xs: A[]) => B[];
60 export function concatMap<A, B>(f: (x: A) => B[], xs: A[]): B[];
61 export function flatten(xs: any[]): any[];
62 export function difference<A>(...xss: A[][]): A[];
63 export function intersection<A>(...xss: A[][]): A[];
64 export function union<A>(...xss: A[][]): A[];
65 export function countBy<A, B>(f: (x: A) => B): (xs: A[]) => any;
66 export function countBy<A, B>(f: (x: A) => B, xs: A[]): any;
67 export function groupBy<A, B>(f: (x: A) => B): (xs: A[]) => any;
68 export function groupBy<A, B>(f: (x: A) => B, xs: A[]): any;
69 export function andList<A>(xs: A[]): boolean;
70 export function orList<A>(xs: A[]): boolean;
71 export function any<A>(f: (x: A) => boolean): (xs: A[]) => boolean;
72 export function any<A>(f: (x: A) => boolean, xs: A[]): boolean;
73 export function all<A>(f: (x: A) => boolean): (xs: A[]) => boolean;
74 export function all<A>(f: (x: A) => boolean, xs: A[]): boolean;
75 export function sort<A>(xs: A[]): A[];
76 export function sortWith<A>(f: (x: A) => (y: A) => number): (xs: A[]) => A[];
77 export function sortWith<A>(f: (x: A) => (y: A) => number, xs: A[]): A[];
78 export function sortBy<A, B>(f: (x: A) => B): (xs: A[]) => A[];
79 export function sortBy<A, B>(f: (x: A) => B, xs: A[]): A[];
80 export function sum(xs: number[]): number;
81 export function product(xs: number[]): number;
82 export function mean(xs: number[]): number;
83 export function maximum<A>(xs: A[]): A;
84 export function minimum<A>(xs: A[]): A;
85 export function maximumBy<A, B>(f: (x: A) => B): (xs: A[]) => A;
86 export function maximumBy<A, B>(f: (x: A) => B, xs: A[]): A;
87 export function minimumBy<A, B>(f: (x: A) => B): (xs: A[]) => A;
88 export function minimumBy<A, B>(f: (x: A) => B, xs: A[]): A;
89 export function scan<A, B>(f: (x: A) => (y: B) => A): (memo: A) => (xs: B[]) => A[];
90 export function scan<A, B>(f: (x: A) => (y: B) => A, memo: A): (xs: B[]) => A[];
91 export function scan<A, B>(f: (x: A) => (y: B) => A, memo: A, xs: B[]): A[];
92 export function scanl<A, B>(f: (x: A) => (y: B) => A): (memo: A) => (xs: B[]) => A[];
93 export function scanl<A, B>(f: (x: A) => (y: B) => A, memo: A): (xs: B[]) => A[];
94 export function scanl<A, B>(f: (x: A) => (y: B) => A, memo: A, xs: B[]): A[];
95 export function scan1<A>(f: (x: A) => (y: A) => A): (xs: A[]) => A[];
96 export function scan1<A>(f: (x: A) => (y: A) => A, xs: A[]): A[];
97 export function scanl1<A>(f: (x: A) => (y: A) => A): (xs: A[]) => A[];
98 export function scanl1<A>(f: (x: A) => (y: A) => A, xs: A[]): A[];
99 export function scanr<A, B>(f: (x: A) => (y: B) => B): (memo: B) => (xs: A[]) => B[];
100 export function scanr<A, B>(f: (x: A) => (y: B) => B, memo: B): (xs: A[]) => B[];
101 export function scanr<A, B>(f: (x: A) => (y: B) => B, memo: B, xs: A[]): B[];
102 export function scanr1<A>(f: (x: A) => (y: A) => A): (xs: A[]) => A[];
103 export function scanr1<A>(f: (x: A) => (y: A) => A, xs: A[]): A[];
104 export function slice<A>(x: number): (y: number) => (xs: A[]) => A[];
105 export function slice<A>(x: number, y: number): (xs: A[]) => A[];
106 export function slice<A>(x: number, y: number, xs: A[]): A[];
107 export function take<A>(n: number): (xs: A[]) => A[];
108 export function take<A>(n: number, xs: A[]): A[];
109 export function drop<A>(n: number): (xs: A[]) => A[];
110 export function drop<A>(n: number, xs: A[]): A[];
111 export function splitAt<A>(n: number): (xs: A[]) => [A[], A[]];
112 export function splitAt<A>(n: number, xs: A[]): [A[], A[]];
113 export function takeWhile<A>(p: (x: A) => boolean): (xs: A[]) => A[];
114 export function takeWhile<A>(p: (x: A) => boolean, xs: A[]): A[];
115 export function dropWhile<A>(p: (x: A) => boolean): (xs: A[]) => A[];
116 export function dropWhile<A>(p: (x: A) => boolean, xs: A[]): A[];
117 export function span<A>(p: (x: A) => boolean): (xs: A[]) => [A[], A[]];
118 export function span<A>(p: (x: A) => boolean, xs: A[]): [A[], A[]];
119 export function breakList<A>(p: (x: A) => boolean): (xs: A[]) => [A[], A[]];
120 export function breakList<A>(p: (x: A) => boolean, xs: A[]): [A[], A[]];
121 export function zip<A, B>(xs: A[]): (ys: B[]) => [A, B][];
122 export function zip<A, B>(xs: A[], ys: B[]): [A, B][];
123 export function zipWith<A, B, C>(f: (x: A) => (y: B) => C): (xs: A[]) => (ys: B[]) => C[];
124 export function zipWith<A, B, C>(f: (x: A) => (y: B) => C, xs: A[]): (ys: B[]) => C[];
125 export function zipWith<A, B, C>(f: (x: A) => (y: B) => C, xs: A[], ys: B[]): C[];
126 export function zipAll<A>(...xss: A[][]): A[][];
127 export function zipAllWith<A, B>(f: (...xs: A[]) => B, ...xss: A[][]): B[];
128 export function at<A>(n: number): (xs: A[]) => A;
129 export function at<A>(n: number, xs: A[]): A;
130 export function elemIndex<A>(x: A): (xs: A[]) => number;
131 export function elemIndex<A>(x: A, xs: A[]): number;
132 export function elemIndices<A>(x: A): (xs: A[]) => number[];
133 export function elemIndices<A>(x: A, xs: A[]): number[];
134 export function findIndex<A>(f: (x: A) => boolean): (xs: A[]) => number;
135 export function findIndex<A>(f: (x: A) => boolean, xs: A[]): number;
136 export function findIndices<A>(f: (x: A) => boolean): (xs: A[]) => number[];
137 export function findIndices<A>(f: (x: A) => boolean, xs: A[]): number[];
138
139
140 // Obj
141
142 export function keys<A>(object: { [key: string]: A }): string[];
143 export function keys<A>(object: { [key: number]: A }): number[];
144 export function values<A>(object: { [key: string]: A }): A[];
145 export function values<A>(object: { [key: number]: A }): A[];
146 export function pairsToObj<A>(object: [string, A][]): { [key: string]: A };
147 export function pairsToObj<A>(object: [number, A][]): { [key: number]: A };
148 export function objToPairs<A>(object: { [key: string]: A }): [string, A][];
149 export function objToPairs<A>(object: { [key: number]: A }): [number, A][];
150 export function listsToObj<A>(keys: string[]): (values: A[]) => { [key: string]: A };
151 export function listsToObj<A>(keys: string[], values: A[]): { [key: string]: A };
152 export function listsToObj<A>(keys: number[]): (values: A[]) => { [key: number]: A };
153 export function listsToObj<A>(keys: number[], values: A[]): { [key: number]: A };
154 export function objToLists<A>(object: { [key: string]: A }): [string[], A[]];
155 export function objToLists<A>(object: { [key: number]: A }): [number[], A[]];
156 export function empty<A>(object: any): boolean;
157 export function each<A>(f: (x: A) => void): (object: { [key: string]: A }) => { [key: string]: A };
158 export function each<A>(f: (x: A) => void, object: { [key: string]: A }): { [key: string]: A };
159 export function each<A>(f: (x: A) => void): (object: { [key: number]: A }) => { [key: number]: A };
160 export function each<A>(f: (x: A) => void, object: { [key: number]: A }): { [key: number]: A };
161 export function map<A, B>(f: (x: A) => B): (object: { [key: string]: A }) => { [key: string]: B };
162 export function map<A, B>(f: (x: A) => B, object: { [key: string]: A }): { [key: string]: B };
163 export function map<A, B>(f: (x: A) => B): (object: { [key: number]: A }) => { [key: number]: B };
164 export function map<A, B>(f: (x: A) => B, object: { [key: number]: A }): { [key: number]: B };
165 export function compact<A>(object: { [key: string]: A }): { [key: string]: A };
166 export function compact<A>(object: { [key: number]: A }): { [key: number]: A };
167 export function filter<A>(f: (x: A) => boolean): (object: { [key: string]: A }) => { [key: string]: A };
168 export function filter<A>(f: (x: A) => boolean, object: { [key: string]: A }): { [key: string]: A };
169 export function filter<A>(f: (x: A) => boolean): (object: { [key: number]: A }) => { [key: number]: A };
170 export function filter<A>(f: (x: A) => boolean, object: { [key: number]: A }): { [key: number]: A };
171 export function reject<A>(f: (x: A) => boolean): (object: { [key: string]: A }) => { [key: string]: A };
172 export function reject<A>(f: (x: A) => boolean, object: { [key: string]: A }): { [key: string]: A };
173 export function reject<A>(f: (x: A) => boolean): (object: { [key: number]: A }) => { [key: number]: A };
174 export function reject<A>(f: (x: A) => boolean, object: { [key: number]: A }): { [key: number]: A };
175 export function partition<A>(f: (x: A) => boolean): (object: { [key: string]: A }) => [{ [key: string]: A }, { [key: string]: A }];
176 export function partition<A>(f: (x: A) => boolean, object: { [key: string]: A }): [{ [key: string]: A }, { [key: string]: A }];
177 export function partition<A>(f: (x: A) => boolean): (object: { [key: number]: A }) => [{ [key: number]: A }, { [key: number]: A }];
178 export function partition<A>(f: (x: A) => boolean, object: { [key: number]: A }): [{ [key: number]: A }, { [key: number]: A }];
179 export function find<A>(f: (x: A) => boolean): (object: { [key: string]: A }) => A;
180 export function find<A>(f: (x: A) => boolean, object: { [key: string]: A }): A;
181 export function find<A>(f: (x: A) => boolean): (object: { [key: number]: A }) => A;
182 export function find<A>(f: (x: A) => boolean, object: { [key: number]: A }): A;
183
184 export module Obj {
185 export function empty<A>(object: any): boolean;
186 export function each<A>(f: (x: A) => void): (object: { [key: string]: A }) => { [key: string]: A };
187 export function each<A>(f: (x: A) => void, object: { [key: string]: A }): { [key: string]: A };
188 export function each<A>(f: (x: A) => void): (object: { [key: number]: A }) => { [key: number]: A };
189 export function each<A>(f: (x: A) => void, object: { [key: number]: A }): { [key: number]: A };
190 export function map<A, B>(f: (x: A) => B): (object: { [key: string]: A }) => { [key: string]: B };
191 export function map<A, B>(f: (x: A) => B, object: { [key: string]: A }): { [key: string]: B };
192 export function map<A, B>(f: (x: A) => B): (object: { [key: number]: A }) => { [key: number]: B };
193 export function map<A, B>(f: (x: A) => B, object: { [key: number]: A }): { [key: number]: B };
194 export function compact<A>(object: { [key: string]: A }): { [key: string]: A };
195 export function compact<A>(object: { [key: number]: A }): { [key: number]: A };
196 export function filter<A>(f: (x: A) => boolean): (object: { [key: string]: A }) => { [key: string]: A };
197 export function filter<A>(f: (x: A) => boolean, object: { [key: string]: A }): { [key: string]: A };
198 export function filter<A>(f: (x: A) => boolean): (object: { [key: number]: A }) => { [key: number]: A };
199 export function filter<A>(f: (x: A) => boolean, object: { [key: number]: A }): { [key: number]: A };
200 export function reject<A>(f: (x: A) => boolean): (object: { [key: string]: A }) => { [key: string]: A };
201 export function reject<A>(f: (x: A) => boolean, object: { [key: string]: A }): { [key: string]: A };
202 export function reject<A>(f: (x: A) => boolean): (object: { [key: number]: A }) => { [key: number]: A };
203 export function reject<A>(f: (x: A) => boolean, object: { [key: number]: A }): { [key: number]: A };
204 export function partition<A>(f: (x: A) => boolean): (object: { [key: string]: A }) => [{ [key: string]: A }, { [key: string]: A }];
205 export function partition<A>(f: (x: A) => boolean, object: { [key: string]: A }): [{ [key: string]: A }, { [key: string]: A }];
206 export function partition<A>(f: (x: A) => boolean): (object: { [key: number]: A }) => [{ [key: number]: A }, { [key: number]: A }];
207 export function partition<A>(f: (x: A) => boolean, object: { [key: number]: A }): [{ [key: number]: A }, { [key: number]: A }];
208 export function find<A>(f: (x: A) => boolean): (object: { [key: string]: A }) => A;
209 export function find<A>(f: (x: A) => boolean, object: { [key: string]: A }): A;
210 export function find<A>(f: (x: A) => boolean): (object: { [key: number]: A }) => A;
211 export function find<A>(f: (x: A) => boolean, object: { [key: number]: A }): A;
212 }
213
214
215 // Str
216
217 export function split(separator: string): (str: string) => string[];
218 export function split(separator: string, str: string): string[];
219 export function join(separator: string): (xs: string[]) => string;
220 export function join(separator: string, xs: string[]): string;
221 export function lines(str: string): string[];
222 export function unlines(xs: string[]): string;
223 export function words(str: string): string[];
224 export function unwords(xs: string[]): string;
225 export function chars(str: string): string[];
226 export function unchars(xs: string[]): string;
227 export function repeat(n: number): (str: string) => string;
228 export function repeat(n: number, str: string): string;
229 export function capitalize(str: string): string;
230 export function camelize(str: string): string;
231 export function dasherize(str: string): string;
232 export function empty(str: string): boolean;
233 export function reverse(str: string): string;
234 export function slice(x: number): (y: number) => (str: string) => string;
235 export function slice(x: number, y: number): (str: string) => string;
236 export function slice(x: number, y: number, str: string): string;
237 export function take(n: number): (str: string) => string;
238 export function take(n: number, str: string): string;
239 export function drop(n: number): (str: string) => string;
240 export function drop(n: number, str: string): string;
241 export function splitAt(n: number): (str: string) => [string, string];
242 export function splitAt(n: number, str: string): [string, string];
243 export function takeWhile(f: (str: string) => boolean): (str: string) => string;
244 export function takeWhile(f: (str: string) => boolean, str: string): string;
245 export function dropWhile(f: (str: string) => boolean): (str: string) => string;
246 export function dropWhile(f: (str: string) => boolean, str: string): string;
247 export function span(f: (str: string) => boolean): (str: string) => [string, string];
248 export function span(f: (str: string) => boolean, str: string): [string, string];
249 export function breakStr(f: (str: string) => boolean): (str: string) => [string, string];
250 export function breakStr(f: (str: string) => boolean, str: string): [string, string];
251
252 export module Str {
253 export function empty(str: string): boolean;
254 export function reverse(str: string): string;
255 export function slice(x: number): (y: number) => (str: string) => string;
256 export function slice(x: number, y: number): (str: string) => string;
257 export function slice(x: number, y: number, str: string): string;
258 export function take(n: number): (str: string) => string;
259 export function take(n: number, str: string): string;
260 export function drop(n: number): (str: string) => string;
261 export function drop(n: number, str: string): string;
262 export function splitAt(n: number): (str: string) => [string, string];
263 export function splitAt(n: number, str: string): [string, string];
264 export function takeWhile(f: (str: string) => boolean): (str: string) => string;
265 export function takeWhile(f: (str: string) => boolean, str: string): string;
266 export function dropWhile(f: (str: string) => boolean): (str: string) => string;
267 export function dropWhile(f: (str: string) => boolean, str: string): string;
268 export function span(f: (str: string) => boolean): (str: string) => [string, string];
269 export function span(f: (str: string) => boolean, str: string): [string, string];
270 export function breakStr(f: (str: string) => boolean): (str: string) => [string, string];
271 export function breakStr(f: (str: string) => boolean, str: string): [string, string];
272 }
273
274
275 // Func
276
277 export function apply<A, B>(f: (...args: A[]) => B): (args: A[]) => B;
278 export function apply<A, B>(f: (...args: A[]) => B, args: A[]): B;
279 export function curry(f: Function): Function;
280 export function flip<A, B, C>(f: (x: A) => (y: B) => C): (y: B) => (x: A) => C;
281 export function flip<A, B, C>(f: (x: A) => (y: B) => C, y: B): (x: A) => C;
282 export function flip<A, B, C>(f: (x: A) => (y: B) => C, y: B, x: A): C;
283 export function fix(f: Function): Function;
284
285 export function over<A, B, C>(f: (x: B) => (y: B) => C | ((x: B, y: B) => C), g: (x: A) => B, x: A, y: A): C;
286 export function over<A, B, C>(f: (x: B, y: B) => C | ((x: B) => (y: B) => C), g: (x: A) => B, x: A): (y: A) => C;
287 export function over<A, B, C>(f: (x: B, y: B) => C, g: (x: A) => B): (x: A, y: A) => C;
288 export function over<A, B, C>(f: (x: B) => (y: B) => C, g: (x: A) => B): (x: A) => (y: A) => C;
289 export function over<A, B, C>(f: (x: B, y: B) => C): (g: (x: A) => B) => (x: A, y: A) => C;
290 export function over<A, B, C>(f: (x: B) => (y: B) => C): (g: (x: A) => B) => (x: A) => (y: A) => C;
291
292
293 // Num
294
295 export function max<Comparable>(x: Comparable): (y: Comparable) => Comparable;
296 export function max<Comparable>(x: Comparable, y: Comparable): Comparable;
297 export function min<Comparable>(x: Comparable): (y: Comparable) => Comparable;
298 export function min<Comparable>(x: Comparable, y: Comparable): Comparable;
299 export function negate(x: number): number;
300 export function abs(x: number): number;
301 export function signum(x: number): number;
302 export function quot(x: number): (y: number) => number;
303 export function quot(x: number, y: number): number;
304 export function rem(x: number): (y: number) => number;
305 export function rem(x: number, y: number): number;
306 export function div(x: number): (y: number) => number;
307 export function div(x: number, y: number): number;
308 export function mod(x: number): (y: number) => number;
309 export function mod(x: number, y: number): number;
310 export function recip(x: number): number;
311 export var pi: number;
312 export var tau: number;
313 export function exp(x: number): number;
314 export function sqrt(x: number): number;
315 export function ln(x: number): number;
316 export function pow(x: number): (y: number) => number;
317 export function pow(x: number, y: number): number;
318 export function sin(x: number): number;
319 export function cos(x: number): number;
320 export function tan(x: number): number;
321 export function asin(x: number): number;
322 export function acos(x: number): number;
323 export function atan(x: number): number;
324 export function atan2(x: number, y: number): number;
325 export function truncate(x: number): number;
326 export function round(x: number): number;
327 export function ceiling(x: number): number;
328 export function floor(x: number): number;
329 export function isItNaN(x: number): boolean;
330 export function even(x: number): boolean;
331 export function odd(x: number): boolean;
332 export function gcd(x: number): (y: number) => number;
333 export function gcd(x: number, y: number): number;
334 export function lcm(x: number): (y: number) => number;
335 export function lcm(x: number, y: number): number;
336}
337
338export = PreludeLS;