@plylang/prelude 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1679 -2
- package/dist/Alt.d.ply +16 -0
- package/dist/Alt.js +2 -0
- package/dist/Alternative.d.ply +13 -0
- package/dist/Alternative.js +16 -0
- package/dist/Applicative.d.ply +23 -0
- package/dist/Applicative.js +18 -0
- package/dist/Apply.d.ply +31 -0
- package/dist/Apply.js +37 -0
- package/dist/Arithmetic.d.ply +83 -0
- package/dist/Arithmetic.js +54 -0
- package/dist/Bifunctor.d.ply +12 -0
- package/dist/Bifunctor.js +13 -0
- package/dist/Chain.d.ply +22 -0
- package/dist/Chain.js +9 -0
- package/dist/Composition.d.ply +16 -0
- package/dist/Composition.js +38 -0
- package/dist/Filterable.d.ply +28 -0
- package/dist/Filterable.js +14 -0
- package/dist/Foldable.d.ply +63 -0
- package/dist/Foldable.js +238 -0
- package/dist/Functor.d.ply +17 -0
- package/dist/Functor.js +12 -0
- package/dist/Group.d.ply +10 -0
- package/dist/Logical.d.ply +37 -0
- package/dist/Logical.js +20 -0
- package/dist/Monad.d.ply +10 -0
- package/dist/Monoid.d.ply +32 -0
- package/dist/Monoid.js +21 -0
- package/dist/Ord.d.ply +67 -0
- package/dist/Ord.js +106 -0
- package/dist/Plus.d.ply +16 -0
- package/dist/Plus.js +13 -0
- package/dist/Prelude.d.ply +47 -0
- package/dist/Prelude.js +15 -0
- package/dist/Semigroup.d.ply +30 -0
- package/dist/Semigroup.js +19 -0
- package/dist/Setoid.d.ply +45 -0
- package/dist/Setoid.js +25 -0
- package/dist/Show.d.ply +45 -0
- package/dist/Show.js +34 -0
- package/dist/Traversable.d.ply +31 -0
- package/dist/Traversable.js +134 -0
- package/dist/Types.d.ply +39 -0
- package/dist/Types.js +8 -0
- package/foreign/Alt.js +3 -0
- package/foreign/Applicative.js +3 -0
- package/foreign/Apply.js +9 -0
- package/foreign/Arithmetic.js +57 -0
- package/foreign/Chain.js +9 -0
- package/foreign/Filterable.js +13 -0
- package/foreign/Foldable.js +29 -0
- package/foreign/Functor.js +3 -0
- package/foreign/Logical.js +11 -0
- package/foreign/Ord.js +34 -0
- package/foreign/Semigroup.js +7 -0
- package/foreign/Setoid.js +24 -0
- package/foreign/Show.js +20 -0
- package/foreign/Traversable.js +3 -0
- package/foreign/Types.js +52 -0
- package/package.json +131 -4
package/README.md
CHANGED
|
@@ -1,3 +1,1680 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @plylang/prelude
|
|
2
|
+
|
|
3
|
+
- [@plylang/prelude/Alt](#plylangpreludealt)
|
|
4
|
+
- [@plylang/prelude/Alternative](#plylangpreludealternative)
|
|
5
|
+
- [@plylang/prelude/Applicative](#plylangpreludeapplicative)
|
|
6
|
+
- [@plylang/prelude/Apply](#plylangpreludeapply)
|
|
7
|
+
- [@plylang/prelude/Arithmetic](#plylangpreludearithmetic)
|
|
8
|
+
- [@plylang/prelude/Bifunctor](#plylangpreludebifunctor)
|
|
9
|
+
- [@plylang/prelude/Chain](#plylangpreludechain)
|
|
10
|
+
- [@plylang/prelude/Composition](#plylangpreludecomposition)
|
|
11
|
+
- [@plylang/prelude/Filterable](#plylangpreludefilterable)
|
|
12
|
+
- [@plylang/prelude/Foldable](#plylangpreludefoldable)
|
|
13
|
+
- [@plylang/prelude/Functor](#plylangpreludefunctor)
|
|
14
|
+
- [@plylang/prelude/Group](#plylangpreludegroup)
|
|
15
|
+
- [@plylang/prelude/Logical](#plylangpreludelogical)
|
|
16
|
+
- [@plylang/prelude/Monad](#plylangpreludemonad)
|
|
17
|
+
- [@plylang/prelude/Monoid](#plylangpreludemonoid)
|
|
18
|
+
- [@plylang/prelude/Ord](#plylangpreludeord)
|
|
19
|
+
- [@plylang/prelude/Plus](#plylangpreludeplus)
|
|
20
|
+
- [@plylang/prelude/Prelude](#plylangpreludeprelude)
|
|
21
|
+
- [@plylang/prelude/Semigroup](#plylangpreludesemigroup)
|
|
22
|
+
- [@plylang/prelude/Setoid](#plylangpreludesetoid)
|
|
23
|
+
- [@plylang/prelude/Show](#plylangpreludeshow)
|
|
24
|
+
- [@plylang/prelude/Traversable](#plylangpreludetraversable)
|
|
25
|
+
- [@plylang/prelude/Types](#plylangpreludetypes)
|
|
26
|
+
|
|
27
|
+
## @plylang/prelude/Alt
|
|
28
|
+
|
|
29
|
+
### Classes
|
|
30
|
+
|
|
31
|
+
#### Alt
|
|
32
|
+
|
|
33
|
+
```ply
|
|
34
|
+
& Functor f => Alt f
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Keep the lower value when it is a result, otherwise the upper one.
|
|
38
|
+
An array keeps both, lower first.
|
|
39
|
+
|
|
40
|
+
#### alt
|
|
41
|
+
|
|
42
|
+
```ply
|
|
43
|
+
alt ( Alt f => (f a) (f a) -- (f a) )
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The lower value when it is a result, otherwise the upper one.
|
|
47
|
+
|
|
48
|
+
### Instances
|
|
49
|
+
|
|
50
|
+
- Alt Array
|
|
51
|
+
|
|
52
|
+
## @plylang/prelude/Alternative
|
|
53
|
+
|
|
54
|
+
### Classes
|
|
55
|
+
|
|
56
|
+
#### Alternative
|
|
57
|
+
|
|
58
|
+
```ply
|
|
59
|
+
& Applicative f, Plus f => Alternative f
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
One constraint brings of, alt, and zero.
|
|
63
|
+
|
|
64
|
+
### Words
|
|
65
|
+
|
|
66
|
+
#### guard
|
|
67
|
+
|
|
68
|
+
```ply
|
|
69
|
+
: guard ( Alternative f => Bool -- (f Unit) )
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
true is of Unit. false is zero.
|
|
73
|
+
|
|
74
|
+
## @plylang/prelude/Applicative
|
|
75
|
+
|
|
76
|
+
### Classes
|
|
77
|
+
|
|
78
|
+
#### Applicative
|
|
79
|
+
|
|
80
|
+
```ply
|
|
81
|
+
& Apply f => Applicative f
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Put one value into the container.
|
|
85
|
+
|
|
86
|
+
#### of
|
|
87
|
+
|
|
88
|
+
```ply
|
|
89
|
+
of ( Applicative f => a -- (f a) )
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The container of this one value.
|
|
93
|
+
|
|
94
|
+
### Instances
|
|
95
|
+
|
|
96
|
+
- Applicative Array
|
|
97
|
+
|
|
98
|
+
### Words
|
|
99
|
+
|
|
100
|
+
#### append
|
|
101
|
+
|
|
102
|
+
```ply
|
|
103
|
+
: append ( Applicative f => Semigroup (f a) => (f a) a -- (f a) )
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The container with this value joined after it.
|
|
107
|
+
|
|
108
|
+
#### prepend
|
|
109
|
+
|
|
110
|
+
```ply
|
|
111
|
+
: prepend ( Applicative f => Semigroup (f a) => (f a) a -- (f a) )
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The container with this value joined before it.
|
|
115
|
+
|
|
116
|
+
## @plylang/prelude/Apply
|
|
117
|
+
|
|
118
|
+
### Classes
|
|
119
|
+
|
|
120
|
+
#### Apply
|
|
121
|
+
|
|
122
|
+
```ply
|
|
123
|
+
& Functor f => Apply f
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Apply a container of quotations. The quotations are on top.
|
|
127
|
+
|
|
128
|
+
#### ap
|
|
129
|
+
|
|
130
|
+
```ply
|
|
131
|
+
ap ( Apply f => (f a) (f (a -- b)) -- (f b) )
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Each value run with the quotation beside it. The quotations are on top.
|
|
135
|
+
|
|
136
|
+
### Instances
|
|
137
|
+
|
|
138
|
+
- Apply Array
|
|
139
|
+
|
|
140
|
+
### Words
|
|
141
|
+
|
|
142
|
+
#### lift2
|
|
143
|
+
|
|
144
|
+
```ply
|
|
145
|
+
: lift2 ( Apply f => (f a) (f b) (a b -- c) -- (f c) )
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Pass two container values, from the bottom upward, to one quotation.
|
|
149
|
+
map takes the lower value. ap takes the upper one. The quotation stays uncurried.
|
|
150
|
+
|
|
151
|
+
#### lift3
|
|
152
|
+
|
|
153
|
+
```ply
|
|
154
|
+
: lift3 ( Apply f => (f a) (f b) (f c) (a b c -- d) -- (f d) )
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Pass three container values, from the bottom upward, to one quotation.
|
|
158
|
+
map takes the first value. ap takes the other two. The quotation stays uncurried.
|
|
159
|
+
|
|
160
|
+
#### apFirst
|
|
161
|
+
|
|
162
|
+
```ply
|
|
163
|
+
: apFirst ( Apply f => (f a) (f b) -- (f a) )
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Keep the lower container's value. The upper container still runs.
|
|
167
|
+
|
|
168
|
+
#### apSecond
|
|
169
|
+
|
|
170
|
+
```ply
|
|
171
|
+
: apSecond ( Apply f => (f a) (f b) -- (f b) )
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Keep the upper container's value. The lower container still runs.
|
|
175
|
+
|
|
176
|
+
## @plylang/prelude/Arithmetic
|
|
177
|
+
|
|
178
|
+
### Classes
|
|
179
|
+
|
|
180
|
+
#### Arithmetic
|
|
181
|
+
|
|
182
|
+
```ply
|
|
183
|
+
& Arithmetic a
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Arithmetic methods share one instance.
|
|
187
|
+
|
|
188
|
+
#### add
|
|
189
|
+
|
|
190
|
+
```ply
|
|
191
|
+
add ( Arithmetic a => a a -- a )
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
The lower value plus the upper one.
|
|
195
|
+
|
|
196
|
+
#### sub
|
|
197
|
+
|
|
198
|
+
```ply
|
|
199
|
+
sub ( Arithmetic a => a a -- a )
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
The upper value subtracted from the lower one.
|
|
203
|
+
|
|
204
|
+
#### mult
|
|
205
|
+
|
|
206
|
+
```ply
|
|
207
|
+
mult ( Arithmetic a => a a -- a )
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
The lower value times the upper one.
|
|
211
|
+
|
|
212
|
+
#### div
|
|
213
|
+
|
|
214
|
+
```ply
|
|
215
|
+
div ( Arithmetic a => a a -- a )
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
The lower value divided by the upper one. A zero divisor throws.
|
|
219
|
+
|
|
220
|
+
#### mod
|
|
221
|
+
|
|
222
|
+
```ply
|
|
223
|
+
mod ( Arithmetic a => a a -- a )
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
The remainder. A zero divisor throws.
|
|
227
|
+
|
|
228
|
+
#### negate
|
|
229
|
+
|
|
230
|
+
```ply
|
|
231
|
+
negate ( Arithmetic a => a -- a )
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
The sign flipped.
|
|
235
|
+
|
|
236
|
+
#### zero
|
|
237
|
+
|
|
238
|
+
```ply
|
|
239
|
+
zero ( Arithmetic a => -- a )
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
The value add leaves unchanged.
|
|
243
|
+
|
|
244
|
+
#### one
|
|
245
|
+
|
|
246
|
+
```ply
|
|
247
|
+
one ( Arithmetic a => -- a )
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
The value multiply leaves unchanged.
|
|
251
|
+
|
|
252
|
+
### Instances
|
|
253
|
+
|
|
254
|
+
- Arithmetic Int
|
|
255
|
+
- Arithmetic Num
|
|
256
|
+
|
|
257
|
+
### Words
|
|
258
|
+
|
|
259
|
+
#### inc
|
|
260
|
+
|
|
261
|
+
```ply
|
|
262
|
+
: inc ( Arithmetic a => a -- a )
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
#### dec
|
|
266
|
+
|
|
267
|
+
```ply
|
|
268
|
+
: dec ( Arithmetic a => a -- a )
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
#### abs
|
|
272
|
+
|
|
273
|
+
```ply
|
|
274
|
+
: abs ( Arithmetic a => Ord a => a -- a )
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
The value with a negative sign flipped. NaN stays NaN, and -0 stays -0.
|
|
278
|
+
|
|
279
|
+
## @plylang/prelude/Bifunctor
|
|
280
|
+
|
|
281
|
+
### Classes
|
|
282
|
+
|
|
283
|
+
#### Bifunctor
|
|
284
|
+
|
|
285
|
+
```ply
|
|
286
|
+
& Bifunctor f
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Map both parameters. The left quotation is under the right one.
|
|
290
|
+
|
|
291
|
+
#### bimap
|
|
292
|
+
|
|
293
|
+
```ply
|
|
294
|
+
bimap ( Bifunctor f => (f a c) (a -- b) (c -- d) -- (f b d) )
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Left quotation under the right one.
|
|
298
|
+
|
|
299
|
+
### Words
|
|
300
|
+
|
|
301
|
+
#### mapLeft
|
|
302
|
+
|
|
303
|
+
```ply
|
|
304
|
+
: mapLeft ( Bifunctor f => (f a c) (a -- b) -- (f b c) )
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
#### mapRight
|
|
308
|
+
|
|
309
|
+
```ply
|
|
310
|
+
: mapRight ( Bifunctor f => (f a c) (c -- b) -- (f a b) )
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## @plylang/prelude/Chain
|
|
314
|
+
|
|
315
|
+
### Classes
|
|
316
|
+
|
|
317
|
+
#### Chain
|
|
318
|
+
|
|
319
|
+
```ply
|
|
320
|
+
& Apply f => Chain f
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Apply a quotation that returns a container, and join the results. The quotation is on top.
|
|
324
|
+
|
|
325
|
+
#### chain
|
|
326
|
+
|
|
327
|
+
```ply
|
|
328
|
+
chain ( Chain f => (f a) (a -- (f b)) -- (f b) )
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
The containers the quotation returns, joined into one.
|
|
332
|
+
|
|
333
|
+
### Instances
|
|
334
|
+
|
|
335
|
+
- Chain Array
|
|
336
|
+
|
|
337
|
+
### Words
|
|
338
|
+
|
|
339
|
+
#### join
|
|
340
|
+
|
|
341
|
+
```ply
|
|
342
|
+
: join ( Chain f => (f (f a)) -- (f a) )
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
One layer removed. The inner container is the result.
|
|
346
|
+
|
|
347
|
+
## @plylang/prelude/Composition
|
|
348
|
+
|
|
349
|
+
### Words
|
|
350
|
+
|
|
351
|
+
#### compose
|
|
352
|
+
|
|
353
|
+
```ply
|
|
354
|
+
: compose ( (a -- b) (b -- c) -- (a -- c) )
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
Runs the lower quotation first and the upper one second.
|
|
358
|
+
A function type cannot be an instance head, so composition is a pair of words.
|
|
359
|
+
|
|
360
|
+
#### id
|
|
361
|
+
|
|
362
|
+
```ply
|
|
363
|
+
: id ( -- (a -- a) )
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
A quotation that returns its input.
|
|
367
|
+
|
|
368
|
+
#### curry2
|
|
369
|
+
|
|
370
|
+
```ply
|
|
371
|
+
: curry2 ( (a b -- c) -- (a -- (b -- c)) )
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Split a binary quotation into unary steps, so ap can take one value at a time.
|
|
375
|
+
|
|
376
|
+
#### curry3
|
|
377
|
+
|
|
378
|
+
```ply
|
|
379
|
+
: curry3 ( (a b c -- d) -- (a -- (b -- (c -- d))) )
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
Split a ternary quotation into unary steps, so ap can take one value at a time.
|
|
383
|
+
|
|
384
|
+
## @plylang/prelude/Filterable
|
|
385
|
+
|
|
386
|
+
### Classes
|
|
387
|
+
|
|
388
|
+
#### Filterable
|
|
389
|
+
|
|
390
|
+
```ply
|
|
391
|
+
& Filterable f
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
filter keeps values the quotation accepts.
|
|
395
|
+
partition leaves the matches below and the rest on top.
|
|
396
|
+
filterMap keeps Some. partitionMap leaves Right below and Left on top.
|
|
397
|
+
|
|
398
|
+
#### filter
|
|
399
|
+
|
|
400
|
+
```ply
|
|
401
|
+
filter ( Filterable f => (f a) (a -- Bool) -- (f a) )
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
Values the quotation accepts.
|
|
405
|
+
|
|
406
|
+
#### partition
|
|
407
|
+
|
|
408
|
+
```ply
|
|
409
|
+
partition ( Filterable f => (f a) (a -- Bool) -- (f a) (f a) )
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
Matches below, the rest on top.
|
|
413
|
+
|
|
414
|
+
### Instances
|
|
415
|
+
|
|
416
|
+
- Filterable Array
|
|
417
|
+
|
|
418
|
+
### Words
|
|
419
|
+
|
|
420
|
+
#### reject
|
|
421
|
+
|
|
422
|
+
```ply
|
|
423
|
+
: reject ( Filterable f => (f a) (a -- Bool) -- (f a) )
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
## @plylang/prelude/Foldable
|
|
427
|
+
|
|
428
|
+
### Classes
|
|
429
|
+
|
|
430
|
+
#### Foldable
|
|
431
|
+
|
|
432
|
+
```ply
|
|
433
|
+
& Foldable f
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
fold walks from the left. The initial value sits under the quotation.
|
|
437
|
+
size, all, any, none, elem, intercalate, foldMap and reverse are in Words/Fold.
|
|
438
|
+
sort and sortBy are in Words/Sort.
|
|
439
|
+
size counts with Num. Importing Num here cycles through Option.
|
|
440
|
+
|
|
441
|
+
#### fold
|
|
442
|
+
|
|
443
|
+
```ply
|
|
444
|
+
fold ( Foldable f => (f a) b (b a -- b) -- b )
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
Walk from the left. The initial value sits under the quotation.
|
|
448
|
+
|
|
449
|
+
### Instances
|
|
450
|
+
|
|
451
|
+
- Foldable Array
|
|
452
|
+
|
|
453
|
+
### Words
|
|
454
|
+
|
|
455
|
+
#### size
|
|
456
|
+
|
|
457
|
+
```ply
|
|
458
|
+
: size ( Foldable f => (f a) -- Num )
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
How many elements. An empty structure is 0.
|
|
462
|
+
|
|
463
|
+
#### all
|
|
464
|
+
|
|
465
|
+
```ply
|
|
466
|
+
: all ( Foldable f => (f a) (a -- Bool) -- Bool )
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
True when every element suits the quotation. An empty structure is true.
|
|
470
|
+
|
|
471
|
+
#### any
|
|
472
|
+
|
|
473
|
+
```ply
|
|
474
|
+
: any ( Foldable f => (f a) (a -- Bool) -- Bool )
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
True when one element suits the quotation. An empty structure is false.
|
|
478
|
+
|
|
479
|
+
#### none
|
|
480
|
+
|
|
481
|
+
```ply
|
|
482
|
+
: none ( Foldable f => (f a) (a -- Bool) -- Bool )
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
True when no element suits the quotation. An empty structure is true.
|
|
486
|
+
|
|
487
|
+
#### elem
|
|
488
|
+
|
|
489
|
+
```ply
|
|
490
|
+
: elem ( Setoid a => Foldable f => (f a) a -- Bool )
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
True when the upper value equals some element.
|
|
494
|
+
|
|
495
|
+
#### intercalate
|
|
496
|
+
|
|
497
|
+
```ply
|
|
498
|
+
: intercalate ( Monoid m => Foldable f => (f m) m -- m )
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
The pieces joined, with the separator between them. An empty structure is empty.
|
|
502
|
+
|
|
503
|
+
#### foldMap
|
|
504
|
+
|
|
505
|
+
```ply
|
|
506
|
+
: foldMap ( Monoid m => Foldable f => (f a) (a -- m) -- m )
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
Concat each result, starting from empty.
|
|
510
|
+
|
|
511
|
+
#### reverse
|
|
512
|
+
|
|
513
|
+
```ply
|
|
514
|
+
: reverse ( Applicative f => Foldable f => Monoid (f a) => (f a) -- (f a) )
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
The elements in the opposite order.
|
|
518
|
+
|
|
519
|
+
#### sortBy
|
|
520
|
+
|
|
521
|
+
```ply
|
|
522
|
+
: sortBy ( Ord b => Applicative f => Foldable f => Monoid (f a) => (f a) (a -- b) -- (f a) )
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
The elements ordered by the quotation, using lte on each result.
|
|
526
|
+
An equal result keeps the earlier element.
|
|
527
|
+
|
|
528
|
+
#### sort
|
|
529
|
+
|
|
530
|
+
```ply
|
|
531
|
+
: sort ( Ord a => Applicative f => Foldable f => Monoid (f a) => (f a) -- (f a) )
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
The elements ordered by lte. An equal element keeps the earlier place.
|
|
535
|
+
|
|
536
|
+
## @plylang/prelude/Functor
|
|
537
|
+
|
|
538
|
+
### Classes
|
|
539
|
+
|
|
540
|
+
#### Functor
|
|
541
|
+
|
|
542
|
+
```ply
|
|
543
|
+
& Functor f
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
Apply a quotation inside the container. The quotation is on top.
|
|
547
|
+
|
|
548
|
+
#### map
|
|
549
|
+
|
|
550
|
+
```ply
|
|
551
|
+
map ( Functor f => (f a) (a -- b) -- (f b) )
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
The container of results. The quotation is on top.
|
|
555
|
+
|
|
556
|
+
### Instances
|
|
557
|
+
|
|
558
|
+
- Functor Array
|
|
559
|
+
|
|
560
|
+
### Words
|
|
561
|
+
|
|
562
|
+
#### flip
|
|
563
|
+
|
|
564
|
+
```ply
|
|
565
|
+
: flip ( Functor f => a (f (a -- b)) -- (f b) )
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
## @plylang/prelude/Group
|
|
569
|
+
|
|
570
|
+
### Classes
|
|
571
|
+
|
|
572
|
+
#### Group
|
|
573
|
+
|
|
574
|
+
```ply
|
|
575
|
+
& Monoid g => Group g
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
A monoid whose concat has an inverse. No prelude type is an instance.
|
|
579
|
+
|
|
580
|
+
#### invert
|
|
581
|
+
|
|
582
|
+
```ply
|
|
583
|
+
invert ( Group g => g -- g )
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
The value that concats back to empty.
|
|
587
|
+
|
|
588
|
+
## @plylang/prelude/Logical
|
|
589
|
+
|
|
590
|
+
### Classes
|
|
591
|
+
|
|
592
|
+
#### Logical
|
|
593
|
+
|
|
594
|
+
```ply
|
|
595
|
+
& Logical a
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
Conjunction, disjunction, negation, and implication.
|
|
599
|
+
truth and falsity are the constants, because true and false are keywords.
|
|
600
|
+
|
|
601
|
+
#### and
|
|
602
|
+
|
|
603
|
+
```ply
|
|
604
|
+
and ( Logical a => a a -- a )
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
Conjunction.
|
|
608
|
+
|
|
609
|
+
#### or
|
|
610
|
+
|
|
611
|
+
```ply
|
|
612
|
+
or ( Logical a => a a -- a )
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
Disjunction.
|
|
616
|
+
|
|
617
|
+
#### not
|
|
618
|
+
|
|
619
|
+
```ply
|
|
620
|
+
not ( Logical a => a -- a )
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
The opposite value.
|
|
624
|
+
|
|
625
|
+
#### truth
|
|
626
|
+
|
|
627
|
+
```ply
|
|
628
|
+
truth ( Logical a => -- a )
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
The constant that and leaves unchanged.
|
|
632
|
+
|
|
633
|
+
#### falsity
|
|
634
|
+
|
|
635
|
+
```ply
|
|
636
|
+
falsity ( Logical a => -- a )
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
The constant that or leaves unchanged.
|
|
640
|
+
|
|
641
|
+
### Instances
|
|
642
|
+
|
|
643
|
+
- Logical Bool
|
|
644
|
+
|
|
645
|
+
### Words
|
|
646
|
+
|
|
647
|
+
#### implies
|
|
648
|
+
|
|
649
|
+
```ply
|
|
650
|
+
: implies ( Logical a => a a -- a )
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
The lower value implies the upper one.
|
|
654
|
+
|
|
655
|
+
## @plylang/prelude/Monad
|
|
656
|
+
|
|
657
|
+
### Classes
|
|
658
|
+
|
|
659
|
+
#### Monad
|
|
660
|
+
|
|
661
|
+
```ply
|
|
662
|
+
& Applicative m, Chain m => Monad m
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
One constraint brings both of and chain.
|
|
666
|
+
|
|
667
|
+
## @plylang/prelude/Monoid
|
|
668
|
+
|
|
669
|
+
### Classes
|
|
670
|
+
|
|
671
|
+
#### Monoid
|
|
672
|
+
|
|
673
|
+
```ply
|
|
674
|
+
& Semigroup a => Monoid a
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
The empty value of a semigroup. Concat with empty changes nothing.
|
|
678
|
+
|
|
679
|
+
#### empty
|
|
680
|
+
|
|
681
|
+
```ply
|
|
682
|
+
empty ( Monoid a => -- a )
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
The value concat leaves unchanged.
|
|
686
|
+
|
|
687
|
+
### Instances
|
|
688
|
+
|
|
689
|
+
- Monoid Str
|
|
690
|
+
- Monoid Unit
|
|
691
|
+
- Monoid (Array a)
|
|
692
|
+
- Monoid Ordering
|
|
693
|
+
|
|
694
|
+
## @plylang/prelude/Ord
|
|
695
|
+
|
|
696
|
+
### Classes
|
|
697
|
+
|
|
698
|
+
#### Ord
|
|
699
|
+
|
|
700
|
+
```ply
|
|
701
|
+
& Setoid a => Ord a
|
|
702
|
+
```
|
|
703
|
+
|
|
704
|
+
A total order. The lower value is compared with the upper one.
|
|
705
|
+
|
|
706
|
+
#### lte
|
|
707
|
+
|
|
708
|
+
```ply
|
|
709
|
+
lte ( Ord a => a a -- Bool )
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
True when the lower value is below the upper one, or they match.
|
|
713
|
+
|
|
714
|
+
### Instances
|
|
715
|
+
|
|
716
|
+
- Ord Str
|
|
717
|
+
- Ord Num
|
|
718
|
+
- Ord Int
|
|
719
|
+
- Ord Bool
|
|
720
|
+
- Ord Unit
|
|
721
|
+
- Ord (Array a)
|
|
722
|
+
- Ord Ordering
|
|
723
|
+
|
|
724
|
+
### Words
|
|
725
|
+
|
|
726
|
+
#### lt
|
|
727
|
+
|
|
728
|
+
```ply
|
|
729
|
+
: lt ( Ord a => a a -- Bool )
|
|
730
|
+
```
|
|
731
|
+
|
|
732
|
+
True when the lower value is below the upper one.
|
|
733
|
+
|
|
734
|
+
#### gt
|
|
735
|
+
|
|
736
|
+
```ply
|
|
737
|
+
: gt ( Ord a => a a -- Bool )
|
|
738
|
+
```
|
|
739
|
+
|
|
740
|
+
True when the lower value is above the upper one.
|
|
741
|
+
|
|
742
|
+
#### gte
|
|
743
|
+
|
|
744
|
+
```ply
|
|
745
|
+
: gte ( Ord a => a a -- Bool )
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
True when the lower value is above the upper one, or they match.
|
|
749
|
+
|
|
750
|
+
#### min
|
|
751
|
+
|
|
752
|
+
```ply
|
|
753
|
+
: min ( Ord a => a a -- a )
|
|
754
|
+
```
|
|
755
|
+
|
|
756
|
+
The smaller value. The lower one stays when they match.
|
|
757
|
+
|
|
758
|
+
#### max
|
|
759
|
+
|
|
760
|
+
```ply
|
|
761
|
+
: max ( Ord a => a a -- a )
|
|
762
|
+
```
|
|
763
|
+
|
|
764
|
+
The larger value. The upper one stays when they match.
|
|
765
|
+
|
|
766
|
+
#### clamp
|
|
767
|
+
|
|
768
|
+
```ply
|
|
769
|
+
: clamp ( Ord a => a a a -- a )
|
|
770
|
+
```
|
|
771
|
+
|
|
772
|
+
Lower bound, upper bound, then the value. A value outside the bounds becomes the nearer bound.
|
|
773
|
+
|
|
774
|
+
#### compare
|
|
775
|
+
|
|
776
|
+
```ply
|
|
777
|
+
: compare ( Ord a => a a -- Ordering )
|
|
778
|
+
```
|
|
779
|
+
|
|
780
|
+
## @plylang/prelude/Plus
|
|
781
|
+
|
|
782
|
+
### Classes
|
|
783
|
+
|
|
784
|
+
#### Plus
|
|
785
|
+
|
|
786
|
+
```ply
|
|
787
|
+
& Alt f => Plus f
|
|
788
|
+
```
|
|
789
|
+
|
|
790
|
+
The value that loses to every other one. alt with it changes nothing.
|
|
791
|
+
|
|
792
|
+
#### init
|
|
793
|
+
|
|
794
|
+
```ply
|
|
795
|
+
init ( Plus f => -- (f a) )
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
The value that loses. alt with it changes nothing.
|
|
799
|
+
|
|
800
|
+
### Words
|
|
801
|
+
|
|
802
|
+
#### oneOf
|
|
803
|
+
|
|
804
|
+
```ply
|
|
805
|
+
: oneOf ( Foldable t => Plus f => (t (f a)) -- (f a) )
|
|
806
|
+
```
|
|
807
|
+
|
|
808
|
+
Folds with alt, starting from init.
|
|
809
|
+
Maybe keeps the first Just. Array appends every piece, lower first.
|
|
810
|
+
|
|
811
|
+
## @plylang/prelude/Prelude
|
|
812
|
+
|
|
813
|
+
### Types
|
|
814
|
+
|
|
815
|
+
#### Ordering
|
|
816
|
+
|
|
817
|
+
```ply
|
|
818
|
+
; Ordering = LT | EQ | GT
|
|
819
|
+
```
|
|
820
|
+
|
|
821
|
+
LT is below EQ. EQ is below GT.
|
|
822
|
+
|
|
823
|
+
### Classes
|
|
824
|
+
|
|
825
|
+
#### Alt
|
|
826
|
+
|
|
827
|
+
```ply
|
|
828
|
+
& Functor f => Alt f
|
|
829
|
+
```
|
|
830
|
+
|
|
831
|
+
Keep the lower value when it is a result, otherwise the upper one.
|
|
832
|
+
An array keeps both, lower first.
|
|
833
|
+
|
|
834
|
+
#### alt
|
|
835
|
+
|
|
836
|
+
```ply
|
|
837
|
+
alt ( Alt f => (f a) (f a) -- (f a) )
|
|
838
|
+
```
|
|
839
|
+
|
|
840
|
+
The lower value when it is a result, otherwise the upper one.
|
|
841
|
+
|
|
842
|
+
#### Alternative
|
|
843
|
+
|
|
844
|
+
```ply
|
|
845
|
+
& Applicative f, Plus f => Alternative f
|
|
846
|
+
```
|
|
847
|
+
|
|
848
|
+
One constraint brings of, alt, and zero.
|
|
849
|
+
|
|
850
|
+
#### Applicative
|
|
851
|
+
|
|
852
|
+
```ply
|
|
853
|
+
& Apply f => Applicative f
|
|
854
|
+
```
|
|
855
|
+
|
|
856
|
+
Put one value into the container.
|
|
857
|
+
|
|
858
|
+
#### of
|
|
859
|
+
|
|
860
|
+
```ply
|
|
861
|
+
of ( Applicative f => a -- (f a) )
|
|
862
|
+
```
|
|
863
|
+
|
|
864
|
+
The container of this one value.
|
|
865
|
+
|
|
866
|
+
#### Apply
|
|
867
|
+
|
|
868
|
+
```ply
|
|
869
|
+
& Functor f => Apply f
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
Apply a container of quotations. The quotations are on top.
|
|
873
|
+
|
|
874
|
+
#### ap
|
|
875
|
+
|
|
876
|
+
```ply
|
|
877
|
+
ap ( Apply f => (f a) (f (a -- b)) -- (f b) )
|
|
878
|
+
```
|
|
879
|
+
|
|
880
|
+
Each value run with the quotation beside it. The quotations are on top.
|
|
881
|
+
|
|
882
|
+
#### Arithmetic
|
|
883
|
+
|
|
884
|
+
```ply
|
|
885
|
+
& Arithmetic a
|
|
886
|
+
```
|
|
887
|
+
|
|
888
|
+
Arithmetic methods share one instance.
|
|
889
|
+
|
|
890
|
+
#### add
|
|
891
|
+
|
|
892
|
+
```ply
|
|
893
|
+
add ( Arithmetic a => a a -- a )
|
|
894
|
+
```
|
|
895
|
+
|
|
896
|
+
The lower value plus the upper one.
|
|
897
|
+
|
|
898
|
+
#### sub
|
|
899
|
+
|
|
900
|
+
```ply
|
|
901
|
+
sub ( Arithmetic a => a a -- a )
|
|
902
|
+
```
|
|
903
|
+
|
|
904
|
+
The upper value subtracted from the lower one.
|
|
905
|
+
|
|
906
|
+
#### mult
|
|
907
|
+
|
|
908
|
+
```ply
|
|
909
|
+
mult ( Arithmetic a => a a -- a )
|
|
910
|
+
```
|
|
911
|
+
|
|
912
|
+
The lower value times the upper one.
|
|
913
|
+
|
|
914
|
+
#### div
|
|
915
|
+
|
|
916
|
+
```ply
|
|
917
|
+
div ( Arithmetic a => a a -- a )
|
|
918
|
+
```
|
|
919
|
+
|
|
920
|
+
The lower value divided by the upper one. A zero divisor throws.
|
|
921
|
+
|
|
922
|
+
#### mod
|
|
923
|
+
|
|
924
|
+
```ply
|
|
925
|
+
mod ( Arithmetic a => a a -- a )
|
|
926
|
+
```
|
|
927
|
+
|
|
928
|
+
The remainder. A zero divisor throws.
|
|
929
|
+
|
|
930
|
+
#### negate
|
|
931
|
+
|
|
932
|
+
```ply
|
|
933
|
+
negate ( Arithmetic a => a -- a )
|
|
934
|
+
```
|
|
935
|
+
|
|
936
|
+
The sign flipped.
|
|
937
|
+
|
|
938
|
+
#### zero
|
|
939
|
+
|
|
940
|
+
```ply
|
|
941
|
+
zero ( Arithmetic a => -- a )
|
|
942
|
+
```
|
|
943
|
+
|
|
944
|
+
The value add leaves unchanged.
|
|
945
|
+
|
|
946
|
+
#### one
|
|
947
|
+
|
|
948
|
+
```ply
|
|
949
|
+
one ( Arithmetic a => -- a )
|
|
950
|
+
```
|
|
951
|
+
|
|
952
|
+
The value multiply leaves unchanged.
|
|
953
|
+
|
|
954
|
+
#### Bifunctor
|
|
955
|
+
|
|
956
|
+
```ply
|
|
957
|
+
& Bifunctor f
|
|
958
|
+
```
|
|
959
|
+
|
|
960
|
+
Map both parameters. The left quotation is under the right one.
|
|
961
|
+
|
|
962
|
+
#### bimap
|
|
963
|
+
|
|
964
|
+
```ply
|
|
965
|
+
bimap ( Bifunctor f => (f a c) (a -- b) (c -- d) -- (f b d) )
|
|
966
|
+
```
|
|
967
|
+
|
|
968
|
+
Left quotation under the right one.
|
|
969
|
+
|
|
970
|
+
#### Chain
|
|
971
|
+
|
|
972
|
+
```ply
|
|
973
|
+
& Apply f => Chain f
|
|
974
|
+
```
|
|
975
|
+
|
|
976
|
+
Apply a quotation that returns a container, and join the results. The quotation is on top.
|
|
977
|
+
|
|
978
|
+
#### chain
|
|
979
|
+
|
|
980
|
+
```ply
|
|
981
|
+
chain ( Chain f => (f a) (a -- (f b)) -- (f b) )
|
|
982
|
+
```
|
|
983
|
+
|
|
984
|
+
The containers the quotation returns, joined into one.
|
|
985
|
+
|
|
986
|
+
#### Filterable
|
|
987
|
+
|
|
988
|
+
```ply
|
|
989
|
+
& Filterable f
|
|
990
|
+
```
|
|
991
|
+
|
|
992
|
+
filter keeps values the quotation accepts.
|
|
993
|
+
partition leaves the matches below and the rest on top.
|
|
994
|
+
filterMap keeps Some. partitionMap leaves Right below and Left on top.
|
|
995
|
+
|
|
996
|
+
#### filter
|
|
997
|
+
|
|
998
|
+
```ply
|
|
999
|
+
filter ( Filterable f => (f a) (a -- Bool) -- (f a) )
|
|
1000
|
+
```
|
|
1001
|
+
|
|
1002
|
+
Values the quotation accepts.
|
|
1003
|
+
|
|
1004
|
+
#### partition
|
|
1005
|
+
|
|
1006
|
+
```ply
|
|
1007
|
+
partition ( Filterable f => (f a) (a -- Bool) -- (f a) (f a) )
|
|
1008
|
+
```
|
|
1009
|
+
|
|
1010
|
+
Matches below, the rest on top.
|
|
1011
|
+
|
|
1012
|
+
#### Foldable
|
|
1013
|
+
|
|
1014
|
+
```ply
|
|
1015
|
+
& Foldable f
|
|
1016
|
+
```
|
|
1017
|
+
|
|
1018
|
+
fold walks from the left. The initial value sits under the quotation.
|
|
1019
|
+
size, all, any, none, elem, intercalate, foldMap and reverse are in Words/Fold.
|
|
1020
|
+
sort and sortBy are in Words/Sort.
|
|
1021
|
+
size counts with Num. Importing Num here cycles through Option.
|
|
1022
|
+
|
|
1023
|
+
#### fold
|
|
1024
|
+
|
|
1025
|
+
```ply
|
|
1026
|
+
fold ( Foldable f => (f a) b (b a -- b) -- b )
|
|
1027
|
+
```
|
|
1028
|
+
|
|
1029
|
+
Walk from the left. The initial value sits under the quotation.
|
|
1030
|
+
|
|
1031
|
+
#### Functor
|
|
1032
|
+
|
|
1033
|
+
```ply
|
|
1034
|
+
& Functor f
|
|
1035
|
+
```
|
|
1036
|
+
|
|
1037
|
+
Apply a quotation inside the container. The quotation is on top.
|
|
1038
|
+
|
|
1039
|
+
#### map
|
|
1040
|
+
|
|
1041
|
+
```ply
|
|
1042
|
+
map ( Functor f => (f a) (a -- b) -- (f b) )
|
|
1043
|
+
```
|
|
1044
|
+
|
|
1045
|
+
The container of results. The quotation is on top.
|
|
1046
|
+
|
|
1047
|
+
#### Group
|
|
1048
|
+
|
|
1049
|
+
```ply
|
|
1050
|
+
& Monoid g => Group g
|
|
1051
|
+
```
|
|
1052
|
+
|
|
1053
|
+
A monoid whose concat has an inverse. No prelude type is an instance.
|
|
1054
|
+
|
|
1055
|
+
#### invert
|
|
1056
|
+
|
|
1057
|
+
```ply
|
|
1058
|
+
invert ( Group g => g -- g )
|
|
1059
|
+
```
|
|
1060
|
+
|
|
1061
|
+
The value that concats back to empty.
|
|
1062
|
+
|
|
1063
|
+
#### Logical
|
|
1064
|
+
|
|
1065
|
+
```ply
|
|
1066
|
+
& Logical a
|
|
1067
|
+
```
|
|
1068
|
+
|
|
1069
|
+
Conjunction, disjunction, negation, and implication.
|
|
1070
|
+
truth and falsity are the constants, because true and false are keywords.
|
|
1071
|
+
|
|
1072
|
+
#### and
|
|
1073
|
+
|
|
1074
|
+
```ply
|
|
1075
|
+
and ( Logical a => a a -- a )
|
|
1076
|
+
```
|
|
1077
|
+
|
|
1078
|
+
Conjunction.
|
|
1079
|
+
|
|
1080
|
+
#### or
|
|
1081
|
+
|
|
1082
|
+
```ply
|
|
1083
|
+
or ( Logical a => a a -- a )
|
|
1084
|
+
```
|
|
1085
|
+
|
|
1086
|
+
Disjunction.
|
|
1087
|
+
|
|
1088
|
+
#### not
|
|
1089
|
+
|
|
1090
|
+
```ply
|
|
1091
|
+
not ( Logical a => a -- a )
|
|
1092
|
+
```
|
|
1093
|
+
|
|
1094
|
+
The opposite value.
|
|
1095
|
+
|
|
1096
|
+
#### truth
|
|
1097
|
+
|
|
1098
|
+
```ply
|
|
1099
|
+
truth ( Logical a => -- a )
|
|
1100
|
+
```
|
|
1101
|
+
|
|
1102
|
+
The constant that and leaves unchanged.
|
|
1103
|
+
|
|
1104
|
+
#### falsity
|
|
1105
|
+
|
|
1106
|
+
```ply
|
|
1107
|
+
falsity ( Logical a => -- a )
|
|
1108
|
+
```
|
|
1109
|
+
|
|
1110
|
+
The constant that or leaves unchanged.
|
|
1111
|
+
|
|
1112
|
+
#### Monad
|
|
1113
|
+
|
|
1114
|
+
```ply
|
|
1115
|
+
& Applicative m, Chain m => Monad m
|
|
1116
|
+
```
|
|
1117
|
+
|
|
1118
|
+
One constraint brings both of and chain.
|
|
1119
|
+
|
|
1120
|
+
#### Monoid
|
|
1121
|
+
|
|
1122
|
+
```ply
|
|
1123
|
+
& Semigroup a => Monoid a
|
|
1124
|
+
```
|
|
1125
|
+
|
|
1126
|
+
The empty value of a semigroup. Concat with empty changes nothing.
|
|
1127
|
+
|
|
1128
|
+
#### empty
|
|
1129
|
+
|
|
1130
|
+
```ply
|
|
1131
|
+
empty ( Monoid a => -- a )
|
|
1132
|
+
```
|
|
1133
|
+
|
|
1134
|
+
The value concat leaves unchanged.
|
|
1135
|
+
|
|
1136
|
+
#### Ord
|
|
1137
|
+
|
|
1138
|
+
```ply
|
|
1139
|
+
& Setoid a => Ord a
|
|
1140
|
+
```
|
|
1141
|
+
|
|
1142
|
+
A total order. The lower value is compared with the upper one.
|
|
1143
|
+
|
|
1144
|
+
#### lte
|
|
1145
|
+
|
|
1146
|
+
```ply
|
|
1147
|
+
lte ( Ord a => a a -- Bool )
|
|
1148
|
+
```
|
|
1149
|
+
|
|
1150
|
+
True when the lower value is below the upper one, or they match.
|
|
1151
|
+
|
|
1152
|
+
#### Plus
|
|
1153
|
+
|
|
1154
|
+
```ply
|
|
1155
|
+
& Alt f => Plus f
|
|
1156
|
+
```
|
|
1157
|
+
|
|
1158
|
+
The value that loses to every other one. alt with it changes nothing.
|
|
1159
|
+
|
|
1160
|
+
#### init
|
|
1161
|
+
|
|
1162
|
+
```ply
|
|
1163
|
+
init ( Plus f => -- (f a) )
|
|
1164
|
+
```
|
|
1165
|
+
|
|
1166
|
+
The value that loses. alt with it changes nothing.
|
|
1167
|
+
|
|
1168
|
+
#### Semigroup
|
|
1169
|
+
|
|
1170
|
+
```ply
|
|
1171
|
+
& Semigroup a
|
|
1172
|
+
```
|
|
1173
|
+
|
|
1174
|
+
Join the lower value with the upper one.
|
|
1175
|
+
|
|
1176
|
+
#### concat
|
|
1177
|
+
|
|
1178
|
+
```ply
|
|
1179
|
+
concat ( Semigroup a => a a -- a )
|
|
1180
|
+
```
|
|
1181
|
+
|
|
1182
|
+
The lower value joined with the upper one.
|
|
1183
|
+
|
|
1184
|
+
#### Setoid
|
|
1185
|
+
|
|
1186
|
+
```ply
|
|
1187
|
+
& Setoid a
|
|
1188
|
+
```
|
|
1189
|
+
|
|
1190
|
+
Decide whether two values are equal.
|
|
1191
|
+
|
|
1192
|
+
#### equal
|
|
1193
|
+
|
|
1194
|
+
```ply
|
|
1195
|
+
equal ( Setoid a => a a -- Bool )
|
|
1196
|
+
```
|
|
1197
|
+
|
|
1198
|
+
True when the two values match.
|
|
1199
|
+
|
|
1200
|
+
#### Show
|
|
1201
|
+
|
|
1202
|
+
```ply
|
|
1203
|
+
& Show a
|
|
1204
|
+
```
|
|
1205
|
+
|
|
1206
|
+
Render a value as text.
|
|
1207
|
+
|
|
1208
|
+
#### show
|
|
1209
|
+
|
|
1210
|
+
```ply
|
|
1211
|
+
show ( Show a => a -- Str )
|
|
1212
|
+
```
|
|
1213
|
+
|
|
1214
|
+
The text of this value.
|
|
1215
|
+
|
|
1216
|
+
#### Traversable
|
|
1217
|
+
|
|
1218
|
+
```ply
|
|
1219
|
+
& Foldable f, Functor f => Traversable f
|
|
1220
|
+
```
|
|
1221
|
+
|
|
1222
|
+
Visit each value with a quotation that returns an applicative result, and collect those results in order.
|
|
1223
|
+
Applicative already brings ap and map.
|
|
1224
|
+
|
|
1225
|
+
#### traverse
|
|
1226
|
+
|
|
1227
|
+
```ply
|
|
1228
|
+
traverse ( Traversable f => Applicative m => (f a) (a -- (m b)) -- (m (f b)) )
|
|
1229
|
+
```
|
|
1230
|
+
|
|
1231
|
+
Each value visited by a quotation that returns an applicative result. The results stay in order.
|
|
1232
|
+
|
|
1233
|
+
### Words
|
|
1234
|
+
|
|
1235
|
+
#### guard
|
|
1236
|
+
|
|
1237
|
+
```ply
|
|
1238
|
+
: guard ( Alternative f => Bool -- (f Unit) )
|
|
1239
|
+
```
|
|
1240
|
+
|
|
1241
|
+
true is of Unit. false is zero.
|
|
1242
|
+
|
|
1243
|
+
#### append
|
|
1244
|
+
|
|
1245
|
+
```ply
|
|
1246
|
+
: append ( Applicative f => Semigroup (f a) => (f a) a -- (f a) )
|
|
1247
|
+
```
|
|
1248
|
+
|
|
1249
|
+
The container with this value joined after it.
|
|
1250
|
+
|
|
1251
|
+
#### prepend
|
|
1252
|
+
|
|
1253
|
+
```ply
|
|
1254
|
+
: prepend ( Applicative f => Semigroup (f a) => (f a) a -- (f a) )
|
|
1255
|
+
```
|
|
1256
|
+
|
|
1257
|
+
The container with this value joined before it.
|
|
1258
|
+
|
|
1259
|
+
#### lift2
|
|
1260
|
+
|
|
1261
|
+
```ply
|
|
1262
|
+
: lift2 ( Apply f => (f a) (f b) (a b -- c) -- (f c) )
|
|
1263
|
+
```
|
|
1264
|
+
|
|
1265
|
+
Pass two container values, from the bottom upward, to one quotation.
|
|
1266
|
+
map takes the lower value. ap takes the upper one. The quotation stays uncurried.
|
|
1267
|
+
|
|
1268
|
+
#### lift3
|
|
1269
|
+
|
|
1270
|
+
```ply
|
|
1271
|
+
: lift3 ( Apply f => (f a) (f b) (f c) (a b c -- d) -- (f d) )
|
|
1272
|
+
```
|
|
1273
|
+
|
|
1274
|
+
Pass three container values, from the bottom upward, to one quotation.
|
|
1275
|
+
map takes the first value. ap takes the other two. The quotation stays uncurried.
|
|
1276
|
+
|
|
1277
|
+
#### apFirst
|
|
1278
|
+
|
|
1279
|
+
```ply
|
|
1280
|
+
: apFirst ( Apply f => (f a) (f b) -- (f a) )
|
|
1281
|
+
```
|
|
1282
|
+
|
|
1283
|
+
Keep the lower container's value. The upper container still runs.
|
|
1284
|
+
|
|
1285
|
+
#### apSecond
|
|
1286
|
+
|
|
1287
|
+
```ply
|
|
1288
|
+
: apSecond ( Apply f => (f a) (f b) -- (f b) )
|
|
1289
|
+
```
|
|
1290
|
+
|
|
1291
|
+
Keep the upper container's value. The lower container still runs.
|
|
1292
|
+
|
|
1293
|
+
#### inc
|
|
1294
|
+
|
|
1295
|
+
```ply
|
|
1296
|
+
: inc ( Arithmetic a => a -- a )
|
|
1297
|
+
```
|
|
1298
|
+
|
|
1299
|
+
#### dec
|
|
1300
|
+
|
|
1301
|
+
```ply
|
|
1302
|
+
: dec ( Arithmetic a => a -- a )
|
|
1303
|
+
```
|
|
1304
|
+
|
|
1305
|
+
#### abs
|
|
1306
|
+
|
|
1307
|
+
```ply
|
|
1308
|
+
: abs ( Arithmetic a => Ord a => a -- a )
|
|
1309
|
+
```
|
|
1310
|
+
|
|
1311
|
+
The value with a negative sign flipped. NaN stays NaN, and -0 stays -0.
|
|
1312
|
+
|
|
1313
|
+
#### mapLeft
|
|
1314
|
+
|
|
1315
|
+
```ply
|
|
1316
|
+
: mapLeft ( Bifunctor f => (f a c) (a -- b) -- (f b c) )
|
|
1317
|
+
```
|
|
1318
|
+
|
|
1319
|
+
#### mapRight
|
|
1320
|
+
|
|
1321
|
+
```ply
|
|
1322
|
+
: mapRight ( Bifunctor f => (f a c) (c -- b) -- (f a b) )
|
|
1323
|
+
```
|
|
1324
|
+
|
|
1325
|
+
#### join
|
|
1326
|
+
|
|
1327
|
+
```ply
|
|
1328
|
+
: join ( Chain f => (f (f a)) -- (f a) )
|
|
1329
|
+
```
|
|
1330
|
+
|
|
1331
|
+
One layer removed. The inner container is the result.
|
|
1332
|
+
|
|
1333
|
+
#### compose
|
|
1334
|
+
|
|
1335
|
+
```ply
|
|
1336
|
+
: compose ( (a -- b) (b -- c) -- (a -- c) )
|
|
1337
|
+
```
|
|
1338
|
+
|
|
1339
|
+
Runs the lower quotation first and the upper one second.
|
|
1340
|
+
A function type cannot be an instance head, so composition is a pair of words.
|
|
1341
|
+
|
|
1342
|
+
#### id
|
|
1343
|
+
|
|
1344
|
+
```ply
|
|
1345
|
+
: id ( -- (a -- a) )
|
|
1346
|
+
```
|
|
1347
|
+
|
|
1348
|
+
A quotation that returns its input.
|
|
1349
|
+
|
|
1350
|
+
#### curry2
|
|
1351
|
+
|
|
1352
|
+
```ply
|
|
1353
|
+
: curry2 ( (a b -- c) -- (a -- (b -- c)) )
|
|
1354
|
+
```
|
|
1355
|
+
|
|
1356
|
+
Split a binary quotation into unary steps, so ap can take one value at a time.
|
|
1357
|
+
|
|
1358
|
+
#### curry3
|
|
1359
|
+
|
|
1360
|
+
```ply
|
|
1361
|
+
: curry3 ( (a b c -- d) -- (a -- (b -- (c -- d))) )
|
|
1362
|
+
```
|
|
1363
|
+
|
|
1364
|
+
Split a ternary quotation into unary steps, so ap can take one value at a time.
|
|
1365
|
+
|
|
1366
|
+
#### reject
|
|
1367
|
+
|
|
1368
|
+
```ply
|
|
1369
|
+
: reject ( Filterable f => (f a) (a -- Bool) -- (f a) )
|
|
1370
|
+
```
|
|
1371
|
+
|
|
1372
|
+
#### size
|
|
1373
|
+
|
|
1374
|
+
```ply
|
|
1375
|
+
: size ( Foldable f => (f a) -- Num )
|
|
1376
|
+
```
|
|
1377
|
+
|
|
1378
|
+
How many elements. An empty structure is 0.
|
|
1379
|
+
|
|
1380
|
+
#### all
|
|
1381
|
+
|
|
1382
|
+
```ply
|
|
1383
|
+
: all ( Foldable f => (f a) (a -- Bool) -- Bool )
|
|
1384
|
+
```
|
|
1385
|
+
|
|
1386
|
+
True when every element suits the quotation. An empty structure is true.
|
|
1387
|
+
|
|
1388
|
+
#### any
|
|
1389
|
+
|
|
1390
|
+
```ply
|
|
1391
|
+
: any ( Foldable f => (f a) (a -- Bool) -- Bool )
|
|
1392
|
+
```
|
|
1393
|
+
|
|
1394
|
+
True when one element suits the quotation. An empty structure is false.
|
|
1395
|
+
|
|
1396
|
+
#### none
|
|
1397
|
+
|
|
1398
|
+
```ply
|
|
1399
|
+
: none ( Foldable f => (f a) (a -- Bool) -- Bool )
|
|
1400
|
+
```
|
|
1401
|
+
|
|
1402
|
+
True when no element suits the quotation. An empty structure is true.
|
|
1403
|
+
|
|
1404
|
+
#### elem
|
|
1405
|
+
|
|
1406
|
+
```ply
|
|
1407
|
+
: elem ( Setoid a => Foldable f => (f a) a -- Bool )
|
|
1408
|
+
```
|
|
1409
|
+
|
|
1410
|
+
True when the upper value equals some element.
|
|
1411
|
+
|
|
1412
|
+
#### intercalate
|
|
1413
|
+
|
|
1414
|
+
```ply
|
|
1415
|
+
: intercalate ( Monoid m => Foldable f => (f m) m -- m )
|
|
1416
|
+
```
|
|
1417
|
+
|
|
1418
|
+
The pieces joined, with the separator between them. An empty structure is empty.
|
|
1419
|
+
|
|
1420
|
+
#### foldMap
|
|
1421
|
+
|
|
1422
|
+
```ply
|
|
1423
|
+
: foldMap ( Monoid m => Foldable f => (f a) (a -- m) -- m )
|
|
1424
|
+
```
|
|
1425
|
+
|
|
1426
|
+
Concat each result, starting from empty.
|
|
1427
|
+
|
|
1428
|
+
#### reverse
|
|
1429
|
+
|
|
1430
|
+
```ply
|
|
1431
|
+
: reverse ( Applicative f => Foldable f => Monoid (f a) => (f a) -- (f a) )
|
|
1432
|
+
```
|
|
1433
|
+
|
|
1434
|
+
The elements in the opposite order.
|
|
1435
|
+
|
|
1436
|
+
#### sortBy
|
|
1437
|
+
|
|
1438
|
+
```ply
|
|
1439
|
+
: sortBy ( Ord b => Applicative f => Foldable f => Monoid (f a) => (f a) (a -- b) -- (f a) )
|
|
1440
|
+
```
|
|
1441
|
+
|
|
1442
|
+
The elements ordered by the quotation, using lte on each result.
|
|
1443
|
+
An equal result keeps the earlier element.
|
|
1444
|
+
|
|
1445
|
+
#### sort
|
|
1446
|
+
|
|
1447
|
+
```ply
|
|
1448
|
+
: sort ( Ord a => Applicative f => Foldable f => Monoid (f a) => (f a) -- (f a) )
|
|
1449
|
+
```
|
|
1450
|
+
|
|
1451
|
+
The elements ordered by lte. An equal element keeps the earlier place.
|
|
1452
|
+
|
|
1453
|
+
#### flip
|
|
1454
|
+
|
|
1455
|
+
```ply
|
|
1456
|
+
: flip ( Functor f => a (f (a -- b)) -- (f b) )
|
|
1457
|
+
```
|
|
1458
|
+
|
|
1459
|
+
#### implies
|
|
1460
|
+
|
|
1461
|
+
```ply
|
|
1462
|
+
: implies ( Logical a => a a -- a )
|
|
1463
|
+
```
|
|
1464
|
+
|
|
1465
|
+
The lower value implies the upper one.
|
|
1466
|
+
|
|
1467
|
+
#### lt
|
|
1468
|
+
|
|
1469
|
+
```ply
|
|
1470
|
+
: lt ( Ord a => a a -- Bool )
|
|
1471
|
+
```
|
|
1472
|
+
|
|
1473
|
+
True when the lower value is below the upper one.
|
|
1474
|
+
|
|
1475
|
+
#### gt
|
|
1476
|
+
|
|
1477
|
+
```ply
|
|
1478
|
+
: gt ( Ord a => a a -- Bool )
|
|
1479
|
+
```
|
|
1480
|
+
|
|
1481
|
+
True when the lower value is above the upper one.
|
|
1482
|
+
|
|
1483
|
+
#### gte
|
|
1484
|
+
|
|
1485
|
+
```ply
|
|
1486
|
+
: gte ( Ord a => a a -- Bool )
|
|
1487
|
+
```
|
|
1488
|
+
|
|
1489
|
+
True when the lower value is above the upper one, or they match.
|
|
1490
|
+
|
|
1491
|
+
#### min
|
|
1492
|
+
|
|
1493
|
+
```ply
|
|
1494
|
+
: min ( Ord a => a a -- a )
|
|
1495
|
+
```
|
|
1496
|
+
|
|
1497
|
+
The smaller value. The lower one stays when they match.
|
|
1498
|
+
|
|
1499
|
+
#### max
|
|
1500
|
+
|
|
1501
|
+
```ply
|
|
1502
|
+
: max ( Ord a => a a -- a )
|
|
1503
|
+
```
|
|
1504
|
+
|
|
1505
|
+
The larger value. The upper one stays when they match.
|
|
1506
|
+
|
|
1507
|
+
#### clamp
|
|
1508
|
+
|
|
1509
|
+
```ply
|
|
1510
|
+
: clamp ( Ord a => a a a -- a )
|
|
1511
|
+
```
|
|
1512
|
+
|
|
1513
|
+
Lower bound, upper bound, then the value. A value outside the bounds becomes the nearer bound.
|
|
1514
|
+
|
|
1515
|
+
#### compare
|
|
1516
|
+
|
|
1517
|
+
```ply
|
|
1518
|
+
: compare ( Ord a => a a -- Ordering )
|
|
1519
|
+
```
|
|
1520
|
+
|
|
1521
|
+
#### oneOf
|
|
1522
|
+
|
|
1523
|
+
```ply
|
|
1524
|
+
: oneOf ( Foldable t => Plus f => (t (f a)) -- (f a) )
|
|
1525
|
+
```
|
|
1526
|
+
|
|
1527
|
+
Folds with alt, starting from init.
|
|
1528
|
+
Maybe keeps the first Just. Array appends every piece, lower first.
|
|
1529
|
+
|
|
1530
|
+
#### sequence
|
|
1531
|
+
|
|
1532
|
+
```ply
|
|
1533
|
+
: sequence ( Applicative f => Traversable t => (t (f a)) -- (f (t a)) )
|
|
1534
|
+
```
|
|
1535
|
+
|
|
1536
|
+
The applicative of the traversable. The inner values stay in order.
|
|
1537
|
+
|
|
1538
|
+
## @plylang/prelude/Semigroup
|
|
1539
|
+
|
|
1540
|
+
### Classes
|
|
1541
|
+
|
|
1542
|
+
#### Semigroup
|
|
1543
|
+
|
|
1544
|
+
```ply
|
|
1545
|
+
& Semigroup a
|
|
1546
|
+
```
|
|
1547
|
+
|
|
1548
|
+
Join the lower value with the upper one.
|
|
1549
|
+
|
|
1550
|
+
#### concat
|
|
1551
|
+
|
|
1552
|
+
```ply
|
|
1553
|
+
concat ( Semigroup a => a a -- a )
|
|
1554
|
+
```
|
|
1555
|
+
|
|
1556
|
+
The lower value joined with the upper one.
|
|
1557
|
+
|
|
1558
|
+
### Instances
|
|
1559
|
+
|
|
1560
|
+
- Semigroup Str
|
|
1561
|
+
- Semigroup Unit
|
|
1562
|
+
- Semigroup (Array a)
|
|
1563
|
+
- Semigroup Ordering
|
|
1564
|
+
|
|
1565
|
+
## @plylang/prelude/Setoid
|
|
1566
|
+
|
|
1567
|
+
### Classes
|
|
1568
|
+
|
|
1569
|
+
#### Setoid
|
|
1570
|
+
|
|
1571
|
+
```ply
|
|
1572
|
+
& Setoid a
|
|
1573
|
+
```
|
|
1574
|
+
|
|
1575
|
+
Decide whether two values are equal.
|
|
1576
|
+
|
|
1577
|
+
#### equal
|
|
1578
|
+
|
|
1579
|
+
```ply
|
|
1580
|
+
equal ( Setoid a => a a -- Bool )
|
|
1581
|
+
```
|
|
1582
|
+
|
|
1583
|
+
True when the two values match.
|
|
1584
|
+
|
|
1585
|
+
### Instances
|
|
1586
|
+
|
|
1587
|
+
- Setoid Str
|
|
1588
|
+
- Setoid Num
|
|
1589
|
+
- Setoid Int
|
|
1590
|
+
- Setoid Bool
|
|
1591
|
+
- Setoid Unit
|
|
1592
|
+
- Setoid (Array a)
|
|
1593
|
+
- Setoid Ordering
|
|
1594
|
+
|
|
1595
|
+
## @plylang/prelude/Show
|
|
1596
|
+
|
|
1597
|
+
### Classes
|
|
1598
|
+
|
|
1599
|
+
#### Show
|
|
1600
|
+
|
|
1601
|
+
```ply
|
|
1602
|
+
& Show a
|
|
1603
|
+
```
|
|
1604
|
+
|
|
1605
|
+
Render a value as text.
|
|
1606
|
+
|
|
1607
|
+
#### show
|
|
1608
|
+
|
|
1609
|
+
```ply
|
|
1610
|
+
show ( Show a => a -- Str )
|
|
1611
|
+
```
|
|
1612
|
+
|
|
1613
|
+
The text of this value.
|
|
1614
|
+
|
|
1615
|
+
### Instances
|
|
1616
|
+
|
|
1617
|
+
- Show Str
|
|
1618
|
+
- Show Num
|
|
1619
|
+
- Show Int
|
|
1620
|
+
- Show Bool
|
|
1621
|
+
- Show Unit
|
|
1622
|
+
- Show (Array a)
|
|
1623
|
+
- Show Ordering
|
|
1624
|
+
|
|
1625
|
+
## @plylang/prelude/Traversable
|
|
1626
|
+
|
|
1627
|
+
### Classes
|
|
1628
|
+
|
|
1629
|
+
#### Traversable
|
|
1630
|
+
|
|
1631
|
+
```ply
|
|
1632
|
+
& Foldable f, Functor f => Traversable f
|
|
1633
|
+
```
|
|
1634
|
+
|
|
1635
|
+
Visit each value with a quotation that returns an applicative result, and collect those results in order.
|
|
1636
|
+
Applicative already brings ap and map.
|
|
1637
|
+
|
|
1638
|
+
#### traverse
|
|
1639
|
+
|
|
1640
|
+
```ply
|
|
1641
|
+
traverse ( Traversable f => Applicative m => (f a) (a -- (m b)) -- (m (f b)) )
|
|
1642
|
+
```
|
|
1643
|
+
|
|
1644
|
+
Each value visited by a quotation that returns an applicative result. The results stay in order.
|
|
1645
|
+
|
|
1646
|
+
### Instances
|
|
1647
|
+
|
|
1648
|
+
- Traversable Array
|
|
1649
|
+
|
|
1650
|
+
### Words
|
|
1651
|
+
|
|
1652
|
+
#### sequence
|
|
1653
|
+
|
|
1654
|
+
```ply
|
|
1655
|
+
: sequence ( Applicative f => Traversable t => (t (f a)) -- (f (t a)) )
|
|
1656
|
+
```
|
|
1657
|
+
|
|
1658
|
+
The applicative of the traversable. The inner values stay in order.
|
|
1659
|
+
|
|
1660
|
+
## @plylang/prelude/Types
|
|
1661
|
+
|
|
1662
|
+
### Types
|
|
1663
|
+
|
|
1664
|
+
#### Ordering
|
|
1665
|
+
|
|
1666
|
+
```ply
|
|
1667
|
+
; Ordering = LT | EQ | GT
|
|
1668
|
+
```
|
|
1669
|
+
|
|
1670
|
+
LT is below EQ. EQ is below GT.
|
|
1671
|
+
|
|
1672
|
+
### Instances
|
|
1673
|
+
|
|
1674
|
+
- Nullary Str
|
|
1675
|
+
- Nullary Num
|
|
1676
|
+
- Nullary Int
|
|
1677
|
+
- Nullary Bool
|
|
1678
|
+
- Nullary Unit
|
|
1679
|
+
- Unary Array
|
|
2
1680
|
|
|
3
|
-
This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
|