diff --git a/docs/typeclasses/alternative.md b/docs/typeclasses/alternative.md index 3eaae295cd..1ed2143878 100644 --- a/docs/typeclasses/alternative.md +++ b/docs/typeclasses/alternative.md @@ -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. @@ -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.