Skip to content

Commit

Permalink
Fix the nested unordered list HTML view of docs/typeclasses/alternati…
Browse files Browse the repository at this point in the history
…ve.md
  • Loading branch information
ShapelessCat committed Jan 11, 2023
1 parent 6efe7df commit 5ef0f5f
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 5ef0f5f

Please sign in to comment.