Skip to content

Latest commit

 

History

History
20 lines (14 loc) · 654 Bytes

Alt.md

File metadata and controls

20 lines (14 loc) · 654 Bytes

MODULE Alt

Alt

type class

interface Alt<F> extends Functor<F> {
  alt: <A>(fx: HKT<F, A>, fy: HKT<F, A>) => HKT<F, A>
}

The Alt type class identifies an associative operation on a type constructor. It is similar to Semigroup, except that it applies to types of kind * -> *, like Array or Option, rather than concrete types like string or number.

Alt instances are required to satisfy the following laws:

  1. Associativity: A.alt(A.alt(fa, ga), ha) = A.alt(fa, A.alt(ga, ha))
  2. Distributivity: A.map(A.alt(fa, ga), ab) = A.alt(A.map(fa, ab), A.map(ga, ab))