git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Style tweaks and a few more comments
0583227Gary Burgess
prelude/README.md+44−53
@@ -2,8 +2,6 @@
2
2
3## Module Prelude
3## Module Prelude
4
4
5−
6−
7#### `otherwise`
5#### `otherwise`
8
6
9``` purescript
7``` purescript
@@ -72,8 +70,7 @@ element `id`, just composable morphisms.
72
70
73`Semigroupoid`s should obey the following rule:
71`Semigroupoid`s should obey the following rule:
74
72
75−Association:
73+- Associativity: `p <<< (q <<< r) = (p <<< q) <<< r`
76− `forall p q r. p <<< (q <<< r) = (p <<< q) <<< r`
77
74
78
75
79#### `semigroupoidArr`
76#### `semigroupoidArr`
@@ -102,11 +99,8 @@ class (Semigroupoid a) <= Category a where
102
99
103`Category`s should obey the following rules.
100`Category`s should obey the following rules.
104
101
105−Left Identity:
102+- Left Identity: `id <<< p = p`
106− `forall p. id <<< p = p`
107−
108−Right Identity:
103+- Right Identity: `p <<< id = p`
109− `forall p. p <<< id = p`
110
104
111
105
112#### `categoryArr`
106#### `categoryArr`
@@ -235,11 +229,8 @@ between [`Category`](#category)s that preserves structure.
235
229
236`Functor`s should obey the following rules.
230`Functor`s should obey the following rules.
237
231
238−Identity:
232+- Identity: `(<$>) id = id`
239− `(<$>) id = id`
240−
241−Composition:
233+- Composition: `(<$>) (f <<< g) = (<$> f) <<< (<$> g)`
242− `forall f g. (<$>) (f . g) = ((<$>) f) . ((<$>) g)`
243
234
244
235
245#### `(<#>)`
236#### `(<#>)`
@@ -266,10 +257,9 @@ class (Functor f) <= Apply f where
266`Apply`s are intuitively [`Applicative`](#applicative)s less `pure`, and more formally a
257`Apply`s are intuitively [`Applicative`](#applicative)s less `pure`, and more formally a
267strong lax semi-monoidal endofunctor.
258strong lax semi-monoidal endofunctor.
268
259
269−`Apply`s should obey the following rules.
260+`Apply`s should obey the following rule.
270
261
271−Associative Composition:
262+- Associative Composition: `(<<<) <$> f <*> g <*> h = f <*> (g <*> h)`
272− `forall f g h. (.) <$> f <*> g <*> h = f <*> (g <*> h)`
273
263
274
264
275#### `Applicative`
265#### `Applicative`
@@ -284,17 +274,10 @@ class (Apply f) <= Applicative f where
284
274
285`Applicative`s should obey the following rules.
275`Applicative`s should obey the following rules.
286
276
287−Identity:
277+- Identity: `(pure id) <*> v = v`
288− `forall v. (pure id) <*> v = v`
289−
290−Composition:
278+- Composition: `(pure <<<) <*> f <*> g <*> h = f <*> (g <*> h)`
291− `forall f g h. (pure (.)) <*> f <*> g <*> h = f <*> (g <*> h)`
292−
293−Homomorphism:
294− `forall f x. (pure f) <*> (pure x) = pure (f x)`
279+- Homomorphism: `(pure f) <*> (pure x) = pure (f x)`
295−
296−Interchange:
280+- Interchange: `u <*> (pure y) = (pure ($ y)) <*> u`
297− `forall u y. u <*> (pure y) = (pure (($) y)) <*> u`
298
281
299
282
300#### `liftA1`
283#### `liftA1`
@@ -315,8 +298,7 @@ A `Bind` is an [`Apply`](#apply) with a bind operation which sequentially compos
315
298
316`Bind`s should obey the following rule.
299`Bind`s should obey the following rule.
317
300
318−Associativity:
319− `forall f g x. (x >>= f) >>= g = x >>= (\k => f k >>= g)`
301+- Associativity: `forall f g x. (x >>= f) >>= g = x >>= (\k => f k >>= g)`
320
302
321
303
322#### `Monad`
304#### `Monad`
@@ -330,11 +312,8 @@ more formally though of as a monoid in the category of endofunctors.
330
312
331`Monad`s should obey the following rules.
313`Monad`s should obey the following rules.
332
314
333−Left Identity:
315+- Left Identity: `pure x >>= f = f x`
334− `forall f x. pure x >>= f = f x`
335−
336−Right Identity:
316+- Right Identity: `x >>= pure = x`
337− `forall x. x >>= pure = x`
338
317
339
318
340#### `return`
319#### `return`
@@ -403,7 +382,13 @@ class Semiring a where
403 one :: a
382 one :: a
404```
383```
405
384
406−Addition and multiplication
385+Addition and multiplication, satisfying the following laws:
386+
387+- `a` is a commutative monoid under addition
388+- `a` is a monoid under multiplication
389+- multiplication distributes over addition
390+- multiplication by `zero` annihilates `a`
391+
407
392
408#### `ModuloSemiring`
393#### `ModuloSemiring`
409
394
@@ -413,8 +398,10 @@ class (Semiring a) <= ModuloSemiring a where
413 mod :: a -> a -> a
398 mod :: a -> a -> a
414```
399```
415
400
416−Semiring with modulo operation and division where
401+Addition, multiplication, modulo operation and division, satisfying:
402+
417−```a / b * b + (a `mod` b) = a```
403+- ```a / b * b + (a `mod` b) = a```
404+
418
405
419#### `Ring`
406#### `Ring`
420
407
@@ -423,7 +410,12 @@ class (Semiring a) <= Ring a where
423 (-) :: a -> a -> a
410 (-) :: a -> a -> a
424```
411```
425
412
426−Addition, multiplication, and subtraction
413+Addition, multiplication, and subtraction.
414+
415+Has the same laws as `Semiring` but additionally satisfying:
416+
417+- `a` is an abelian group under addition
418+
427
419
428#### `negate`
420#### `negate`
429
421
@@ -438,8 +430,10 @@ negate :: forall a. (Ring a) => a -> a
438class (Ring a, ModuloSemiring a) <= DivisionRing a where
430class (Ring a, ModuloSemiring a) <= DivisionRing a where
439```
431```
440
432
441−Ring where every nonzero element has a multiplicative inverse (possibly
433+Ring where every nonzero element has a multiplicative inverse so that:
434+
442−a non-commutative field) so that ```a `mod` b = zero```
435+- ```a `mod` b = zero```
436+
443
437
444#### `Num`
438#### `Num`
445
439
@@ -507,6 +501,7 @@ class Eq a where
507 (/=) :: a -> a -> Boolean
501 (/=) :: a -> a -> Boolean
508```
502```
509
503
504+Class for types that have an equality comparison.
510
505
511#### `refEq`
506#### `refEq`
512
507
@@ -595,6 +590,14 @@ class (Eq a) <= Ord a where
595 compare :: a -> a -> Ordering
590 compare :: a -> a -> Ordering
596```
591```
597
592
593+Class for types that have ordered comparisons.
594+
595+Represents a partially ordered set satisfying the following laws:
596+
597+- Reflexivity: `a <= a`
598+- Antisymmetry: if `a <= b` and `b <= a` then `a = b`
599+- Transitivity: if `a <= b` and `b <= c` then `a <= c`
600+
598
601
599#### `(<)`
602#### `(<)`
600
603
@@ -736,8 +739,6 @@ instance semigroupArr :: (Semigroup s') => Semigroup (s -> s')
736
739
737## Module Data.Function
740## Module Data.Function
738
741
739−
740−
741#### `on`
742#### `on`
742
743
743``` purescript
744``` purescript
@@ -979,8 +980,6 @@ runFn10 :: forall a b c d e f g h i j k. Fn10 a b c d e f g h i j k -> a -> b ->
979
980
980## Module Prelude.Unsafe
981## Module Prelude.Unsafe
981
982
982−
983−
984#### `unsafeIndex`
983#### `unsafeIndex`
985
984
986``` purescript
985``` purescript
@@ -991,8 +990,6 @@ unsafeIndex :: forall a. [a] -> Number -> a
991
990
992## Module Control.Monad.Eff
991## Module Control.Monad.Eff
993
992
994−
995−
996#### `Eff`
993#### `Eff`
997
994
998``` purescript
995``` purescript
@@ -1094,8 +1091,6 @@ foreachE :: forall e a. [a] -> (a -> Eff e Unit) -> Eff e Unit
1094
1091
1095## Module Control.Monad.Eff.Unsafe
1092## Module Control.Monad.Eff.Unsafe
1096
1093
1097−
1098−
1099#### `unsafeInterleaveEff`
1094#### `unsafeInterleaveEff`
1100
1095
1101``` purescript
1096``` purescript
@@ -1106,8 +1101,6 @@ unsafeInterleaveEff :: forall eff1 eff2 a. Eff eff1 a -> Eff eff2 a
1106
1101
1107## Module Debug.Trace
1102## Module Debug.Trace
1108
1103
1109−
1110−
1111#### `Trace`
1104#### `Trace`
1112
1105
1113``` purescript
1106``` purescript
@@ -1132,8 +1125,6 @@ print :: forall a r. (Show a) => a -> Eff (trace :: Trace | r) Unit
1132
1125
1133## Module Control.Monad.ST
1126## Module Control.Monad.ST
1134
1127
1135−
1136−
1137#### `ST`
1128#### `ST`
1138
1129
1139``` purescript
1130``` purescript
prelude/prelude.purs+44−40
@@ -77,8 +77,7 @@ module Prelude
77 -- |
77 -- |
78 -- | `Semigroupoid`s should obey the following rule:
78 -- | `Semigroupoid`s should obey the following rule:
79 -- |
79 -- |
80− -- | Association:
80+ -- | - Associativity: `p <<< (q <<< r) = (p <<< q) <<< r`
81− -- | `forall p q r. p <<< (q <<< r) = (p <<< q) <<< r`
82 -- |
81 -- |
83 class Semigroupoid a where
82 class Semigroupoid a where
84 (<<<) :: forall b c d. a c d -> a b c -> a b d
83 (<<<) :: forall b c d. a c d -> a b c -> a b d
@@ -94,11 +93,8 @@ module Prelude
94 -- |
93 -- |
95 -- | `Category`s should obey the following rules.
94 -- | `Category`s should obey the following rules.
96 -- |
95 -- |
97− -- | Left Identity:
96+ -- | - Left Identity: `id <<< p = p`
98− -- | `forall p. id <<< p = p`
99− -- |
100− -- | Right Identity:
97+ -- | - Right Identity: `p <<< id = p`
101− -- | `forall p. p <<< id = p`
102 -- |
98 -- |
103 class (Semigroupoid a) <= Category a where
99 class (Semigroupoid a) <= Category a where
104 id :: forall t. a t t
100 id :: forall t. a t t
@@ -219,11 +215,8 @@ module Prelude
219 -- |
215 -- |
220 -- | `Functor`s should obey the following rules.
216 -- | `Functor`s should obey the following rules.
221 -- |
217 -- |
222− -- | Identity:
218+ -- | - Identity: `(<$>) id = id`
223− -- | `(<$>) id = id`
224− -- |
225− -- | Composition:
219+ -- | - Composition: `(<$>) (f <<< g) = (<$> f) <<< (<$> g)`
226− -- | `forall f g. (<$>) (f . g) = ((<$>) f) . ((<$>) g)`
227 -- |
220 -- |
228 class Functor f where
221 class Functor f where
229 (<$>) :: forall a b. (a -> b) -> f a -> f b
222 (<$>) :: forall a b. (a -> b) -> f a -> f b
@@ -239,10 +232,9 @@ module Prelude
239 -- | `Apply`s are intuitively [`Applicative`](#applicative)s less `pure`, and more formally a
232 -- | `Apply`s are intuitively [`Applicative`](#applicative)s less `pure`, and more formally a
240 -- | strong lax semi-monoidal endofunctor.
233 -- | strong lax semi-monoidal endofunctor.
241 -- |
234 -- |
242− -- | `Apply`s should obey the following rules.
235+ -- | `Apply`s should obey the following rule.
243 -- |
236 -- |
244− -- | Associative Composition:
237+ -- | - Associative Composition: `(<<<) <$> f <*> g <*> h = f <*> (g <*> h)`
245− -- | `forall f g h. (.) <$> f <*> g <*> h = f <*> (g <*> h)`
246 -- |
238 -- |
247 class (Functor f) <= Apply f where
239 class (Functor f) <= Apply f where
248 (<*>) :: forall a b. f (a -> b) -> f a -> f b
240 (<*>) :: forall a b. f (a -> b) -> f a -> f b
@@ -252,17 +244,10 @@ module Prelude
252 -- |
244 -- |
253 -- | `Applicative`s should obey the following rules.
245 -- | `Applicative`s should obey the following rules.
254 -- |
246 -- |
255− -- | Identity:
247+ -- | - Identity: `(pure id) <*> v = v`
256− -- | `forall v. (pure id) <*> v = v`
257− -- |
258− -- | Composition:
248+ -- | - Composition: `(pure <<<) <*> f <*> g <*> h = f <*> (g <*> h)`
259− -- | `forall f g h. (pure (.)) <*> f <*> g <*> h = f <*> (g <*> h)`
260− -- |
261− -- | Homomorphism:
262− -- | `forall f x. (pure f) <*> (pure x) = pure (f x)`
249+ -- | - Homomorphism: `(pure f) <*> (pure x) = pure (f x)`
263− -- |
264− -- | Interchange:
250+ -- | - Interchange: `u <*> (pure y) = (pure ($ y)) <*> u`
265− -- | `forall u y. u <*> (pure y) = (pure (($) y)) <*> u`
266 -- |
251 -- |
267 class (Apply f) <= Applicative f where
252 class (Apply f) <= Applicative f where
268 pure :: forall a. a -> f a
253 pure :: forall a. a -> f a
@@ -276,8 +261,7 @@ module Prelude
276 -- |
261 -- |
277 -- | `Bind`s should obey the following rule.
262 -- | `Bind`s should obey the following rule.
278 -- |
263 -- |
279− -- | Associativity:
280− -- | `forall f g x. (x >>= f) >>= g = x >>= (\k => f k >>= g)`
264+ -- | - Associativity: `forall f g x. (x >>= f) >>= g = x >>= (\k => f k >>= g)`
281 -- |
265 -- |
282 class (Apply m) <= Bind m where
266 class (Apply m) <= Bind m where
283 (>>=) :: forall a b. m a -> (a -> m b) -> m b
267 (>>=) :: forall a b. m a -> (a -> m b) -> m b
@@ -287,11 +271,8 @@ module Prelude
287 -- |
271 -- |
288 -- | `Monad`s should obey the following rules.
272 -- | `Monad`s should obey the following rules.
289 -- |
273 -- |
290− -- | Left Identity:
274+ -- | - Left Identity: `pure x >>= f = f x`
291− -- | `forall f x. pure x >>= f = f x`
292− -- |
293− -- | Right Identity:
275+ -- | - Right Identity: `x >>= pure = x`
294− -- | `forall x. x >>= pure = x`
295 -- |
276 -- |
296 class (Applicative m, Bind m) <= Monad m
277 class (Applicative m, Bind m) <= Monad m
297
278
@@ -330,28 +311,43 @@ module Prelude
330 infixl 6 -
311 infixl 6 -
331 infixl 6 +
312 infixl 6 +
332
313
333− -- | Addition and multiplication
314+ -- | Addition and multiplication, satisfying the following laws:
315+ -- |
316+ -- | - `a` is a commutative monoid under addition
317+ -- | - `a` is a monoid under multiplication
318+ -- | - multiplication distributes over addition
319+ -- | - multiplication by `zero` annihilates `a`
320+ -- |
334 class Semiring a where
321 class Semiring a where
335 (+) :: a -> a -> a
322 (+) :: a -> a -> a
336 zero :: a
323 zero :: a
337 (*) :: a -> a -> a
324 (*) :: a -> a -> a
338 one :: a
325 one :: a
339
326
340− -- | Semiring with modulo operation and division where
327+ -- | Addition, multiplication, modulo operation and division, satisfying:
328+ -- |
341− -- | ```a / b * b + (a `mod` b) = a```
329+ -- | - ```a / b * b + (a `mod` b) = a```
330+ -- |
342 class (Semiring a) <= ModuloSemiring a where
331 class (Semiring a) <= ModuloSemiring a where
343 (/) :: a -> a -> a
332 (/) :: a -> a -> a
344 mod :: a -> a -> a
333 mod :: a -> a -> a
345
334
346− -- | Addition, multiplication, and subtraction
335+ -- | Addition, multiplication, and subtraction.
336+ -- |
337+ -- | Has the same laws as `Semiring` but additionally satisfying:
338+ -- |
339+ -- | - `a` is an abelian group under addition
340+ -- |
347 class (Semiring a) <= Ring a where
341 class (Semiring a) <= Ring a where
348 (-) :: a -> a -> a
342 (-) :: a -> a -> a
349
343
350 negate :: forall a. (Ring a) => a -> a
344 negate :: forall a. (Ring a) => a -> a
351 negate a = zero - a
345 negate a = zero - a
352
346
353− -- | Ring where every nonzero element has a multiplicative inverse (possibly
347+ -- | Ring where every nonzero element has a multiplicative inverse so that:
348+ -- |
354− -- | a non-commutative field) so that ```a `mod` b = zero```
349+ -- | - ```a `mod` b = zero```
350+ -- |
355 class (Ring a, ModuloSemiring a) <= DivisionRing a
351 class (Ring a, ModuloSemiring a) <= DivisionRing a
356
352
357 -- | A commutative field
353 -- | A commutative field
@@ -429,6 +425,7 @@ module Prelude
429 infix 4 ==
425 infix 4 ==
430 infix 4 /=
426 infix 4 /=
431
427
428+ -- | Class for types that have an equality comparison.
432 class Eq a where
429 class Eq a where
433 (==) :: a -> a -> Boolean
430 (==) :: a -> a -> Boolean
434 (/=) :: a -> a -> Boolean
431 (/=) :: a -> a -> Boolean
@@ -505,7 +502,14 @@ module Prelude
505 (<>) GT _ = GT
502 (<>) GT _ = GT
506 (<>) EQ y = y
503 (<>) EQ y = y
507
504
508−
505+ -- | Class for types that have ordered comparisons.
506+ -- |
507+ -- | Represents a partially ordered set satisfying the following laws:
508+ -- |
509+ -- | - Reflexivity: `a <= a`
510+ -- | - Antisymmetry: if `a <= b` and `b <= a` then `a = b`
511+ -- | - Transitivity: if `a <= b` and `b <= c` then `a <= c`
512+ -- |
509 class (Eq a) <= Ord a where
513 class (Eq a) <= Ord a where
510 compare :: a -> a -> Ordering
514 compare :: a -> a -> Ordering
511
515