selective

Selective applicative functors in OCaml
IN THIS PACKAGE
Module Selective . Make

Parameters

module S : Basic

Signature

include Base.Applicative.S with type 'a t = 'a S.t
type 'a t = 'a S.t
val return : 'a -> 'a t
val apply : ( 'a -> 'b ) t -> 'a t -> 'b t
val map : 'a t -> f:( 'a -> 'b ) -> 'b t
val map2 : 'a t -> 'b t -> f:( 'a -> 'b -> 'c ) -> 'c t
val map3 : 'a t -> 'b t -> 'c t -> f:( 'a -> 'b -> 'c -> 'd ) -> 'd t
val all : 'a t list -> 'a list t
val all_unit : unit t list -> unit t
val all_ignore : unit t list -> unit t
val both : 'a t -> 'b t -> ('a * 'b) t
module Applicative_infix : sig ... end
include module type of Applicative_infix
val (<*>) : ( 'a -> 'b ) t -> 'a t -> 'b t

same as apply

val (<*) : 'a t -> unit t -> 'a t
val (*>) : unit t -> 'a t -> 'a t
val select : ( 'a, 'b ) Base.Either.t t -> ( 'a -> 'b ) t -> 'b t
val (<*?) : ( 'a, 'b ) Base.Either.t t -> ( 'a -> 'b ) t -> 'b t

An operator alias for select, which is sometimes convenient. It tries to follow the notational convention for Applicative operators. The angle bracket pointing to the left means we always use the corresponding value. The value on the right, however, may be unnecessary, hence the question mark.

val branch : ( 'a, 'b ) Base.Either.t t -> ( 'a -> 'c ) t -> ( 'b -> 'c ) t -> 'c t

The branch function is a natural generalisation of select: instead of skipping an unnecessary effect, it chooses which of the two given effectful functions to apply to a given argument; the other effect is unnecessary.

val ifS : Base.bool t -> 'a t -> 'a t -> 'a t

Branch on a Boolean value, skipping unnecessary effects.

val whenS : Base.bool t -> Base.unit t -> Base.unit t

Conditionally perform an effect.

val (<||>) : Base.bool t -> Base.bool t -> Base.bool t

A lifted version of lazy Boolean OR.

val (<&&>) : Base.bool t -> Base.bool t -> Base.bool t

A lifted version of lazy Boolean AND.