Skip to content

Commit a3a3cfc

Browse files
committed
Merge pull request #3 from purescript/prim-instances
Additional Prim instances
2 parents dde3f6b + 8a162d4 commit a3a3cfc

File tree

2 files changed

+277
-32
lines changed

2 files changed

+277
-32
lines changed

docs/Prelude.md

Lines changed: 121 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ require an identity element `id`, just composable morphisms.
160160
One example of a `Semigroupoid` is the function type constructor `(->)`,
161161
with `(<<<)` defined as function composition.
162162

163-
#### `semigroupoidArr`
163+
#### `semigroupoidFn`
164164

165165
``` purescript
166-
instance semigroupoidArr :: Semigroupoid Prim.Function
166+
instance semigroupoidFn :: Semigroupoid Prim.Function
167167
```
168168

169169

@@ -198,10 +198,10 @@ Instances must satisfy the following law in addition to the
198198

199199
- Identity: `id <<< p = p <<< id = p`
200200

201-
#### `categoryArr`
201+
#### `categoryFn`
202202

203203
``` purescript
204-
instance categoryArr :: Category Prim.Function
204+
instance categoryFn :: Category Prim.Function
205205
```
206206

207207

@@ -224,10 +224,17 @@ Instances must satisfy the following laws:
224224
- Identity: `(<$>) id = id`
225225
- Composition: `(<$>) (f <<< g) = (f <$>) <<< (g <$>)`
226226

227-
#### `functorArr`
227+
#### `functorFn`
228228

229229
``` purescript
230-
instance functorArr :: Functor (Prim.Function r)
230+
instance functorFn :: Functor (Prim.Function r)
231+
```
232+
233+
234+
#### `functorArray`
235+
236+
``` purescript
237+
instance functorArray :: Functor Prim.Array
231238
```
232239

233240

@@ -299,10 +306,17 @@ laws:
299306

300307
Formally, `Apply` represents a strong lax semi-monoidal endofunctor.
301308

302-
#### `applyArr`
309+
#### `applyFn`
310+
311+
``` purescript
312+
instance applyFn :: Apply (Prim.Function r)
313+
```
314+
315+
316+
#### `applyArray`
303317

304318
``` purescript
305-
instance applyArr :: Apply (Prim.Function r)
319+
instance applyArray :: Apply Prim.Array
306320
```
307321

308322

@@ -339,10 +353,17 @@ laws:
339353
- Homomorphism: `(pure f) <*> (pure x) = pure (f x)`
340354
- Interchange: `u <*> (pure y) = (pure ($ y)) <*> u`
341355

342-
#### `applicativeArr`
356+
#### `applicativeFn`
343357

344358
``` purescript
345-
instance applicativeArr :: Applicative (Prim.Function r)
359+
instance applicativeFn :: Applicative (Prim.Function r)
360+
```
361+
362+
363+
#### `applicativeArray`
364+
365+
``` purescript
366+
instance applicativeArray :: Applicative Prim.Array
346367
```
347368

348369

@@ -407,10 +428,17 @@ do x <- m1
407428
m3 x y
408429
```
409430

410-
#### `bindArr`
431+
#### `bindFn`
432+
433+
``` purescript
434+
instance bindFn :: Bind (Prim.Function r)
435+
```
436+
437+
438+
#### `bindArray`
411439

412440
``` purescript
413-
instance bindArr :: Bind (Prim.Function r)
441+
instance bindArray :: Bind Prim.Array
414442
```
415443

416444

@@ -438,10 +466,17 @@ Instances must satisfy the following laws in addition to the
438466
- Left Identity: `pure x >>= f = f x`
439467
- Right Identity: `x >>= pure = x`
440468

441-
#### `monadArr`
469+
#### `monadFn`
470+
471+
``` purescript
472+
instance monadFn :: Monad (Prim.Function r)
473+
```
474+
475+
476+
#### `monadArray`
442477

443478
``` purescript
444-
instance monadArr :: Monad (Prim.Function r)
479+
instance monadArray :: Monad Prim.Array
445480
```
446481

447482

@@ -527,10 +562,10 @@ instance semigroupUnit :: Semigroup Unit
527562
```
528563

529564

530-
#### `semigroupArr`
565+
#### `semigroupFn`
531566

532567
``` purescript
533-
instance semigroupArr :: (Semigroup s') => Semigroup (s -> s')
568+
instance semigroupFn :: (Semigroup s') => Semigroup (s -> s')
534569
```
535570

536571

@@ -541,6 +576,13 @@ instance semigroupOrdering :: Semigroup Ordering
541576
```
542577

543578

579+
#### `semigroupArray`
580+
581+
``` purescript
582+
instance semigroupArray :: Semigroup [a]
583+
```
584+
585+
544586
#### `Semiring`
545587

546588
``` purescript
@@ -568,6 +610,13 @@ Instances must satisfy the following laws:
568610
- Right distributivity: `(a + b) * c = (a * c) + (b * c)`
569611
- Annihiliation: `zero * a = a * zero = zero`
570612

613+
#### `semiringInt`
614+
615+
``` purescript
616+
instance semiringInt :: Semiring Int
617+
```
618+
619+
571620
#### `semiringNumber`
572621

573622
``` purescript
@@ -611,6 +660,13 @@ laws:
611660

612661
- Additive inverse: `a + (-a) = (-a) + a = zero`
613662

663+
#### `ringInt`
664+
665+
``` purescript
666+
instance ringInt :: Ring Int
667+
```
668+
669+
614670
#### `ringNumber`
615671

616672
``` purescript
@@ -655,6 +711,13 @@ laws:
655711

656712
- Remainder: `a / b * b + (a `mod` b) = a`
657713

714+
#### `moduloSemiringInt`
715+
716+
``` purescript
717+
instance moduloSemiringInt :: ModuloSemiring Int
718+
```
719+
720+
658721
#### `moduloSemiringNumber`
659722

660723
``` purescript
@@ -770,13 +833,27 @@ instance eqBoolean :: Eq Boolean
770833
```
771834

772835

836+
#### `eqInt`
837+
838+
``` purescript
839+
instance eqInt :: Eq Int
840+
```
841+
842+
773843
#### `eqNumber`
774844

775845
``` purescript
776846
instance eqNumber :: Eq Number
777847
```
778848

779849

850+
#### `eqChar`
851+
852+
``` purescript
853+
instance eqChar :: Eq Char
854+
```
855+
856+
780857
#### `eqString`
781858

782859
``` purescript
@@ -843,6 +920,13 @@ instance ordBoolean :: Ord Boolean
843920
```
844921

845922

923+
#### `ordInt`
924+
925+
``` purescript
926+
instance ordInt :: Ord Int
927+
```
928+
929+
846930
#### `ordNumber`
847931

848932
``` purescript
@@ -857,6 +941,13 @@ instance ordString :: Ord String
857941
```
858942

859943

944+
#### `ordChar`
945+
946+
``` purescript
947+
instance ordChar :: Ord Char
948+
```
949+
950+
860951
#### `ordUnit`
861952

862953
``` purescript
@@ -1144,13 +1235,27 @@ instance showBoolean :: Show Boolean
11441235
```
11451236

11461237

1238+
#### `showInt`
1239+
1240+
``` purescript
1241+
instance showInt :: Show Int
1242+
```
1243+
1244+
11471245
#### `showNumber`
11481246

11491247
``` purescript
11501248
instance showNumber :: Show Number
11511249
```
11521250

11531251

1252+
#### `showChar`
1253+
1254+
``` purescript
1255+
instance showChar :: Show Char
1256+
```
1257+
1258+
11541259
#### `showString`
11551260

11561261
``` purescript

0 commit comments

Comments
 (0)