File tree Expand file tree Collapse file tree 4 files changed +24
-24
lines changed Expand file tree Collapse file tree 4 files changed +24
-24
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,15 @@ newtype First a
7
7
= First (Maybe a)
8
8
```
9
9
10
+ Monoid returning the first (left-most) non-` Nothing ` value.
11
+
12
+ ``` purescript
13
+ First (Just x) <> First (Just y) == First (Just x)
14
+ First Nothing <> First (Just y) == First (Just y)
15
+ First Nothing <> Nothing == First Nothing
16
+ mempty :: First _ == First Nothing
17
+ ```
18
+
10
19
##### Instances
11
20
``` purescript
12
21
instance eqFirst :: (Eq a) => Eq (First a)
@@ -24,15 +33,6 @@ instance semigroupFirst :: Semigroup (First a)
24
33
instance monoidFirst :: Monoid (First a)
25
34
```
26
35
27
- Monoid returning the first (left-most) non-` Nothing ` value.
28
-
29
- ``` purescript
30
- First (Just x) <> First (Just y) == First (Just x)
31
- First Nothing <> First (Just y) == First (Just y)
32
- First Nothing <> Nothing == First Nothing
33
- mempty :: First _ == First Nothing
34
- ```
35
-
36
36
#### ` runFirst `
37
37
38
38
``` purescript
Original file line number Diff line number Diff line change @@ -7,6 +7,15 @@ newtype Last a
7
7
= Last (Maybe a)
8
8
```
9
9
10
+ Monoid returning the last (right-most) non-` Nothing ` value.
11
+
12
+ ``` purescript
13
+ Last (Just x) <> Last (Just y) == Last (Just y)
14
+ Last (Just x) <> Nothing == Last (Just x)
15
+ Last Nothing <> Nothing == Last Nothing
16
+ mempty :: Last _ == Last Nothing
17
+ ```
18
+
10
19
##### Instances
11
20
``` purescript
12
21
instance eqLast :: (Eq a) => Eq (Last a)
@@ -24,15 +33,6 @@ instance semigroupLast :: Semigroup (Last a)
24
33
instance monoidLast :: Monoid (Last a)
25
34
```
26
35
27
- Monoid returning the last (right-most) non-` Nothing ` value.
28
-
29
- ``` purescript
30
- Last (Just x) <> Last (Just y) == Last (Just y)
31
- Last (Just x) <> Nothing == Last (Just x)
32
- Last Nothing <> Nothing == Last Nothing
33
- mempty :: Last _ == Last Nothing
34
- ```
35
-
36
36
#### ` runLast `
37
37
38
38
``` purescript
Original file line number Diff line number Diff line change @@ -8,6 +8,10 @@ data Maybe a
8
8
| Just a
9
9
```
10
10
11
+ The ` Maybe ` type is used to represent optional values and can be seen as
12
+ something like a type-safe ` null ` , where ` Nothing ` is ` null ` and ` Just x `
13
+ is the non-null value ` x ` .
14
+
11
15
##### Instances
12
16
``` purescript
13
17
instance functorMaybe :: Functor Maybe
@@ -20,7 +24,7 @@ instance bindMaybe :: Bind Maybe
20
24
instance monadMaybe :: Monad Maybe
21
25
instance monadPlusMaybe :: MonadPlus Maybe
22
26
instance extendMaybe :: Extend Maybe
23
- instance invariantFirst :: Invariant Maybe
27
+ instance invariantMaybe :: Invariant Maybe
24
28
instance semigroupMaybe :: (Semigroup a) => Semigroup (Maybe a)
25
29
instance monoidMaybe :: (Semigroup a) => Monoid (Maybe a)
26
30
instance semiringMaybe :: (Semiring a) => Semiring (Maybe a)
@@ -36,10 +40,6 @@ instance booleanAlgebraMaybe :: (BooleanAlgebra a) => BooleanAlgebra (Maybe a)
36
40
instance showMaybe :: (Show a) => Show (Maybe a)
37
41
```
38
42
39
- The ` Maybe ` type is used to represent optional values and can be seen as
40
- something like a type-safe ` null ` , where ` Nothing ` is ` null ` and ` Just x `
41
- is the non-null value ` x ` .
42
-
43
43
#### ` maybe `
44
44
45
45
``` purescript
Original file line number Diff line number Diff line change @@ -189,7 +189,7 @@ instance extendMaybe :: Extend Maybe where
189
189
extend _ Nothing = Nothing
190
190
extend f x = Just (f x)
191
191
192
- instance invariantFirst :: Invariant Maybe where
192
+ instance invariantMaybe :: Invariant Maybe where
193
193
imap = imapF
194
194
195
195
-- | The `Semigroup` instance enables use of the operator `<>` on `Maybe` values
You can’t perform that action at this time.
0 commit comments