Preface_specs.SelectiveA Selective (applicative functor) allows to declare effects statically and select which execute dynamically. It is an algebraic structure between Applicative and Monad. A Selective is also an Applicative.
To have a predictable behaviour, the instance of Selective must obey some laws.
x <*? pure id = Either.case id id <$> xpure x <*? (y *> z) = (pure x <*? y) *> (pure x <*? z)x <*? (y <*? z) = (f <$> x) <*? (g <$> y) <*? (h <$> z)f <$> select x y) = (select (Bifunctor.map_snd f <$> x) (((%) f) <$> y)(select (Bifunctor.map_fst f <$> x) y) = (select x ((%>) f) <$> y))(select x (f <$> y)) = (select (Bifunctor.map_fst (flip f) <$> x) ((|>) \
<$> y))(x <*? pure y) = (Either.case y id <$> x)(pure (Right x) <*? y) = pure x(pure (Left x) <*? y) = ((|>) x) <$> yA selective is Rigid if apply can be defined in term of select
f <*> g = apply f g(x *> (y <*? z)) = ((x *> y) <*? z)module type WITH_SELECT = sig ... endMinimal definition using select without Applicative requirements.
module type WITH_BRANCH = sig ... endMinimal definition using branch without Applicative requirements.
module type WITH_PURE_AND_SELECT = sig ... endStandard requirement including pure and select.
module type WITH_PURE_AND_BRANCH = sig ... endStandard requirement including pure and branch.
module type CORE = sig ... endBasis operation.
module type OPERATION = sig ... endAdditional operations.
module type SYNTAX = sig ... endSyntax extensions.
module type INFIX = sig ... endInfix operators.
module type API = sig ... endThe complete interface of a Selective.