Preface_specs.Bifunctor
A Bifunctor
is a type constructor that takes two type arguments and is a Functor
(Covariant) in both arguments.
To have a predictable behaviour, the instance of Bifunctor
must obey some laws.
bimap id id = id
map_fst id = id
map_snd id = id
bimap f g = map_fst f % map_snd g
bimap (f % g) (h % i) = bimap f h % bimap g i
map_fst (f % g) = map_fst f % map_snd g
map_snd (f % g) = map_snd f % map_snd g
module type WITH_BIMAP = sig ... end
Minimal interface using bimap
.
module type WITH_MAP_FST_AND_MAP_SND = sig ... end
Minimal interface using map_fst
and map_snd
.
module type CORE = sig ... end
Basis operations.
module type OPERATION = sig ... end
Additional operations.
module type API = sig ... end
The complete interface of a Bifunctor
.