Commit d681f42
authored
fix(maybe): complete instance of applicative (#116)
In order to complete the instance of Applicative, a method "apply" must
be added to the type. Technically, a Monad does not require an instance
of Applicative, but most modern functional languages and libraries
enforce this constraint due to the benefits derived when implementing
instances of other Categories. Particularly in the case of Maybe, this
instance is desirable due to the behavior of Maybes which wrap a
function. Because applying an undefined function to a value results in
an error, rather than undefined or null, mapping a function wrapped by
Maybe demands that the function be unwrapped and coerced to some
default before it can be used, or checking to see if it is defined. The
"apply" method allows a value wrapped by Maybe to be applied to a
function wrapped by Maybe.1 parent 5243fe5 commit d681f42
File tree
3 files changed
+28
-2
lines changed- src
- interfaces
- monads
- test/monads
3 files changed
+28
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | | - | |
| 46 | + | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
495 | 495 | | |
496 | 496 | | |
497 | 497 | | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
498 | 517 | | |
0 commit comments