Skip to content

Commit

Permalink
Merge pull request #4371 from ShapelessCat/fix-nested-unordered-lists…
Browse files Browse the repository at this point in the history
…-html-view-of-alternative.md

Fix the nested unordered list HTML view of docs/typeclasses/alternative.md
  • Loading branch information
armanbilge authored Jan 11, 2023
2 parents 6efe7df + 5ef0f5f commit bbfa146
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions docs/typeclasses/alternative.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Alternative

Alternative extends [`Applicative`](applicative.md) with a [`MonoidK`](monoidk.md).
Let's stub out all the operations just to remind ourselves what that gets us.

Expand All @@ -21,11 +22,13 @@ As you might recall, `pure` wraps values in the context; `ap` allows us to do ca
Like other type classes, `Alternative` instances must obey some laws, in addition to those otherwise applying to `MonoidK` and `Applicative instances`:

* Right Absorption: Applying a contextual function `F[A => B]` to `empty [A]` should be `empty [B]`.
* `ff ap F.empty[A] = F.empty[B]`.
* `ff ap F.empty[A] = F.empty[B]`.

* Left Distributivity: Mapping over a combined element must be the combinations of the mapped elements.
* `(fa <+> fb) map f = ((fa map f) <+> (fb map f))` where `fa: F[A]` and `fb: F[B]` and `f: A => B`.
* `(fa <+> fb) map f = ((fa map f) <+> (fb map f))` where `fa: F[A]` and `fb: F[B]` and `f: A => B`.

* Right Distributivity: Applying the combination of two functions must be the combination of their applications.
* `(ff <+> fg) ap fa = (ff ap fa) <+> (fg ap fa)` where `ff: F[A => B]`, `fg: F[A => B]`, and `fa: F[A]`.
* `(ff <+> fg) ap fa = (ff ap fa) <+> (fg ap fa)` where `ff: F[A => B]`, `fg: F[A => B]`, and `fa: F[A]`.

These laws guarantee the compatibility of the otherwise possibly independent `Applicative` and `MonoidK` structures.

Expand Down

0 comments on commit bbfa146

Please sign in to comment.