Skip to content

Commit 12e6283

Browse files
committed
Add orphan Array instances
1 parent 59981dd commit 12e6283

File tree

9 files changed

+36
-6
lines changed

9 files changed

+36
-6
lines changed

docs/Control.Alt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ types of kind `* -> *`, like `Array` or `List`, rather than concrete types
2222
For example, the `Array` (`[]`) type is an instance of `Alt`, where
2323
`(<|>)` is defined to be concatenation.
2424

25+
##### Instances
26+
``` purescript
27+
instance altArray :: Alt Array
28+
```
29+
2530
#### `(<|>)`
2631

2732
``` purescript

docs/Control.Alternative.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@ laws:
1818
- Distributivity: `(f <|> g) <*> x == (f <*> x) <|> (g <*> x)`
1919
- Annihilation: `empty <*> f = empty`
2020

21+
##### Instances
22+
``` purescript
23+
instance alternativeArray :: Alternative Array
24+
```
25+
2126

docs/Control.Extend.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ class (Functor w) <= Extend w where
99
extend :: forall b a. (w a -> b) -> w a -> w b
1010
```
1111

12-
##### Instances
13-
``` purescript
14-
instance extendFn :: (Semigroup w) => Extend (Function w)
15-
```
16-
1712
The `Extend` class defines the extension operator `(<<=)`
1813
which extends a local context-dependent computation to
1914
a global computation.
@@ -25,6 +20,11 @@ Laws:
2520

2621
- Associativity: `extend f <<< extend g = extend (f <<< extend g)`
2722

23+
##### Instances
24+
``` purescript
25+
instance extendFn :: (Semigroup w) => Extend (Function w)
26+
```
27+
2828
#### `(<<=)`
2929

3030
``` purescript

docs/Control.MonadPlus.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ laws:
1717
- Distributivity: `(x <|> y) >>= f == (x >>= f) <|> (y >>= f)`
1818
- Annihilation: `empty >>= f = empty`
1919

20+
##### Instances
21+
``` purescript
22+
instance monadPlusArray :: MonadPlus Array
23+
```
24+
2025
#### `guard`
2126

2227
``` purescript

docs/Control.Plus.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,9 @@ kind `* -> *`, like `Array` or `List`, rather than concrete types like
2222
- Right identity: `x <|> empty == x`
2323
- Annihilation: `f <$> empty == empty`
2424

25+
##### Instances
26+
``` purescript
27+
instance plusArray :: Plus Array
28+
```
29+
2530

src/Control/Alt.purs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ infixl 3 <|>
2424
-- | An infix version of `alt`.
2525
(<|>) :: forall f a. (Alt f) => f a -> f a -> f a
2626
(<|>) = alt
27+
28+
instance altArray :: Alt Array where
29+
alt = append

src/Control/Alternative.purs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ import Control.Plus
1818
-- | - Distributivity: `(f <|> g) <*> x == (f <*> x) <|> (g <*> x)`
1919
-- | - Annihilation: `empty <*> f = empty`
2020
class (Applicative f, Plus f) <= Alternative f
21+
22+
instance alternativeArray :: Alternative Array

src/Control/MonadPlus.purs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class (Monad m, Alternative m) <= MonadPlus m
2424
-- |
2525
-- | ```purescript
2626
-- | import Data.Array
27-
-- |
27+
-- |
2828
-- | factors :: Number -> Array Number
2929
-- | factors n = do
3030
-- | a <- 1 .. n
@@ -35,3 +35,5 @@ class (Monad m, Alternative m) <= MonadPlus m
3535
guard :: forall m. (MonadPlus m) => Boolean -> m Unit
3636
guard true = return unit
3737
guard false = empty
38+
39+
instance monadPlusArray :: MonadPlus Array

src/Control/Plus.purs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ import Control.Alt
2020
-- | - Annihilation: `f <$> empty == empty`
2121
class (Alt f) <= Plus f where
2222
empty :: forall a. f a
23+
24+
instance plusArray :: Plus Array where
25+
empty = []

0 commit comments

Comments
 (0)