Skip to content

Commit b7a6c29

Browse files
committed
Update operator docs
1 parent c4c6789 commit b7a6c29

File tree

2 files changed

+57
-40
lines changed

2 files changed

+57
-40
lines changed

docs/Prelude.md

+19-8
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ with `(<<<)` defined as function composition.
160160
(<<<) :: forall a b c d. (Semigroupoid a) => a c d -> a b c -> a b d
161161
```
162162

163+
`(<<<)` is an alias for `compose`.
164+
163165
#### `(>>>)`
164166

165167
``` purescript
@@ -220,6 +222,8 @@ Instances must satisfy the following laws:
220222
(<$>) :: forall f a b. (Functor f) => (a -> b) -> f a -> f b
221223
```
222224

225+
`(<$>)` is an alias for `map`
226+
223227
#### `(<#>)`
224228

225229
``` purescript
@@ -293,6 +297,8 @@ Formally, `Apply` represents a strong lax semi-monoidal endofunctor.
293297
(<*>) :: forall f a b. (Apply f) => f (a -> b) -> f a -> f b
294298
```
295299

300+
`(<*>)` is an alias for `apply`.
301+
296302
#### `Applicative`
297303

298304
``` purescript
@@ -398,6 +404,8 @@ do x <- m1
398404
(>>=) :: forall m a b. (Bind m) => m a -> (a -> m b) -> m b
399405
```
400406

407+
`(>>=)` is an alias for `bind`.
408+
401409
#### `Monad`
402410

403411
``` purescript
@@ -496,7 +504,7 @@ concatenation.
496504
(++) :: forall s. (Semigroup s) => s -> s -> s
497505
```
498506

499-
`(++)` is an alias for `append`.
507+
`(++)` is an alternative alias for `append`.
500508

501509
#### `Semiring`
502510

@@ -691,14 +699,17 @@ The `Eq` type class represents types which support decidable equality.
691699
(==) :: forall a. (Eq a) => a -> a -> Boolean
692700
```
693701

694-
`(==)` is an alias for `eq`.
702+
`(==)` is an alias for `eq`. Tests whether one value is equal to another.
695703

696704
#### `(/=)`
697705

698706
``` purescript
699707
(/=) :: forall a. (Eq a) => a -> a -> Boolean
700708
```
701709

710+
`(/=)` tests whether one value is _not equal_ to another. Shorthand for
711+
`not (x == y)`.
712+
702713
#### `Ordering`
703714

704715
``` purescript
@@ -857,21 +868,21 @@ laws:
857868
- `a && not a = bottom`
858869
- `a || not a = top`
859870

860-
#### `(||)`
871+
#### `(&&)`
861872

862873
``` purescript
863-
(||) :: forall a. (BooleanAlgebra a) => a -> a -> a
874+
(&&) :: forall a. (BooleanAlgebra a) => a -> a -> a
864875
```
865876

866-
The `conj` operator.
877+
`(&&)` is an alias for `conj`.
867878

868-
#### `(&&)`
879+
#### `(||)`
869880

870881
``` purescript
871-
(&&) :: forall a. (BooleanAlgebra a) => a -> a -> a
882+
(||) :: forall a. (BooleanAlgebra a) => a -> a -> a
872883
```
873884

874-
The `disj` operator.
885+
`(||)` is an alias for `disj`.
875886

876887
#### `Show`
877888

src/Prelude.purs

+38-32
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ asTypeOf x _ = x
111111
otherwise :: Boolean
112112
otherwise = true
113113

114-
infixr 9 >>>
115-
infixr 9 <<<
116-
117114
-- | A `Semigroupoid` is similar to a [`Category`](#category) but does not
118115
-- | require an identity element `id`, just composable morphisms.
119116
-- |
@@ -129,6 +126,10 @@ class Semigroupoid a where
129126
instance semigroupoidFn :: Semigroupoid (->) where
130127
compose f g x = f (g x)
131128

129+
infixr 9 >>>
130+
infixr 9 <<<
131+
132+
-- | `(<<<)` is an alias for `compose`.
132133
(<<<) :: forall a b c d. (Semigroupoid a) => a c d -> a b c -> a b d
133134
(<<<) = compose
134135

@@ -150,9 +151,6 @@ class (Semigroupoid a) <= Category a where
150151
instance categoryFn :: Category (->) where
151152
id x = x
152153

153-
infixl 4 <$>
154-
infixl 1 <#>
155-
156154
-- | A `Functor` is a type constructor which supports a mapping operation
157155
-- | `(<$>)`.
158156
-- |
@@ -175,6 +173,10 @@ instance functorArray :: Functor Array where
175173

176174
foreign import arrayMap :: forall a b. (a -> b) -> Array a -> Array b
177175

176+
infixl 4 <$>
177+
infixl 1 <#>
178+
179+
-- | `(<$>)` is an alias for `map`
178180
(<$>) :: forall f a b. (Functor f) => (a -> b) -> f a -> f b
179181
(<$>) = map
180182

@@ -201,8 +203,6 @@ foreign import arrayMap :: forall a b. (a -> b) -> Array a -> Array b
201203
void :: forall f a. (Functor f) => f a -> f Unit
202204
void fa = const unit <$> fa
203205

204-
infixl 4 <*>
205-
206206
-- | The `Apply` class provides the `(<*>)` which is used to apply a function
207207
-- | to an argument under a type constructor.
208208
-- |
@@ -234,6 +234,9 @@ instance applyFn :: Apply ((->) r) where
234234
instance applyArray :: Apply Array where
235235
apply = ap
236236

237+
infixl 4 <*>
238+
239+
-- | `(<*>)` is an alias for `apply`.
237240
(<*>) :: forall f a b. (Apply f) => f (a -> b) -> f a -> f b
238241
(<*>) = apply
239242

@@ -283,8 +286,6 @@ return = pure
283286
liftA1 :: forall f a b. (Applicative f) => (a -> b) -> f a -> f b
284287
liftA1 f a = pure f <*> a
285288

286-
infixl 1 >>=
287-
288289
-- | The `Bind` type class extends the [`Apply`](#apply) type class with a
289290
-- | "bind" operation `(>>=)` which composes computations in sequence, using
290291
-- | the return value of one computation to determine the next computation.
@@ -322,6 +323,9 @@ instance bindArray :: Bind Array where
322323

323324
foreign import arrayBind :: forall a b. Array a -> (a -> Array b) -> Array b
324325

326+
infixl 1 >>=
327+
328+
-- | `(>>=)` is an alias for `bind`.
325329
(>>=) :: forall m a b. (Bind m) => m a -> (a -> m b) -> m b
326330
(>>=) = bind
327331

@@ -373,9 +377,6 @@ ap f a = do
373377
a' <- a
374378
return (f' a')
375379

376-
infixr 5 <>
377-
infixr 5 ++
378-
379380
-- | The `Semigroup` type class identifies an associative operation on a type.
380381
-- |
381382
-- | Instances are required to satisfy the following law:
@@ -387,11 +388,14 @@ infixr 5 ++
387388
class Semigroup a where
388389
append :: a -> a -> a
389390

391+
infixr 5 <>
392+
infixr 5 ++
393+
390394
-- | `(<>)` is an alias for `append`.
391395
(<>) :: forall s. (Semigroup s) => s -> s -> s
392396
(<>) = append
393397

394-
-- | `(++)` is an alias for `append`.
398+
-- | `(++)` is an alternative alias for `append`.
395399
(++) :: forall s. (Semigroup s) => s -> s -> s
396400
(++) = append
397401

@@ -415,9 +419,6 @@ instance semigroupArray :: Semigroup (Array a) where
415419
foreign import concatString :: String -> String -> String
416420
foreign import concatArray :: forall a. Array a -> Array a -> Array a
417421

418-
infixl 6 +
419-
infixl 7 *
420-
421422
-- | The `Semiring` class is for types that support an addition and
422423
-- | multiplication operation.
423424
-- |
@@ -458,6 +459,9 @@ instance semiringUnit :: Semiring Unit where
458459
mul _ _ = unit
459460
one = unit
460461

462+
infixl 6 +
463+
infixl 7 *
464+
461465
-- | `(+)` is an alias for `add`.
462466
(+) :: forall a. (Semiring a) => a -> a -> a
463467
(+) = add
@@ -471,8 +475,6 @@ foreign import intMul :: Int -> Int -> Int
471475
foreign import numAdd :: Number -> Number -> Number
472476
foreign import numMul :: Number -> Number -> Number
473477

474-
infixl 6 -
475-
476478
-- | The `Ring` class is for types that support addition, multiplication,
477479
-- | and subtraction operations.
478480
-- |
@@ -492,6 +494,8 @@ instance ringNumber :: Ring Number where
492494
instance ringUnit :: Ring Unit where
493495
sub _ _ = unit
494496

497+
infixl 6 -
498+
495499
-- | `(-)` is an alias for `sub`.
496500
(-) :: forall a. (Ring a) => a -> a -> a
497501
(-) = sub
@@ -503,8 +507,6 @@ negate a = zero - a
503507
foreign import intSub :: Int -> Int -> Int
504508
foreign import numSub :: Number -> Number -> Number
505509

506-
infixl 7 /
507-
508510
-- | The `ModuloSemiring` class is for types that support addition,
509511
-- | multiplication, division, and modulo (division remainder) operations.
510512
-- |
@@ -528,6 +530,8 @@ instance moduloSemiringUnit :: ModuloSemiring Unit where
528530
div _ _ = unit
529531
mod _ _ = unit
530532

533+
infixl 7 /
534+
531535
-- | `(/)` is an alias for `div`.
532536
(/) :: forall a. (ModuloSemiring a) => a -> a -> a
533537
(/) = div
@@ -561,9 +565,6 @@ class (DivisionRing a) <= Num a
561565
instance numNumber :: Num Number
562566
instance numUnit :: Num Unit
563567

564-
infix 4 ==
565-
infix 4 /=
566-
567568
-- | The `Eq` type class represents types which support decidable equality.
568569
-- |
569570
-- | `Eq` instances should satisfy the following laws:
@@ -574,10 +575,15 @@ infix 4 /=
574575
class Eq a where
575576
eq :: a -> a -> Boolean
576577

577-
-- | `(==)` is an alias for `eq`.
578+
infix 4 ==
579+
infix 4 /=
580+
581+
-- | `(==)` is an alias for `eq`. Tests whether one value is equal to another.
578582
(==) :: forall a. (Eq a) => a -> a -> Boolean
579583
(==) = eq
580584

585+
-- | `(/=)` tests whether one value is _not equal_ to another. Shorthand for
586+
-- | `not (x == y)`.
581587
(/=) :: forall a. (Eq a) => a -> a -> Boolean
582588
(/=) x y = not (x == y)
583589

@@ -793,16 +799,16 @@ instance booleanAlgebraFn :: (BooleanAlgebra b) => BooleanAlgebra (a -> b) where
793799
disj fx fy a = fx a `disj` fy a
794800
not fx a = not (fx a)
795801

796-
infixr 2 ||
797802
infixr 3 &&
803+
infixr 2 ||
798804

799-
-- | The `conj` operator.
800-
(||) :: forall a. (BooleanAlgebra a) => a -> a -> a
801-
(||) = conj
802-
803-
-- | The `disj` operator.
805+
-- | `(&&)` is an alias for `conj`.
804806
(&&) :: forall a. (BooleanAlgebra a) => a -> a -> a
805-
(&&) = disj
807+
(&&) = conj
808+
809+
-- | `(||)` is an alias for `disj`.
810+
(||) :: forall a. (BooleanAlgebra a) => a -> a -> a
811+
(||) = disj
806812

807813
foreign import boolOr :: Boolean -> Boolean -> Boolean
808814
foreign import boolAnd :: Boolean -> Boolean -> Boolean

0 commit comments

Comments
 (0)