Preface_stdlib.ValidationImplementation for Validation.t.
Validation is very similar to Result, the main difference between the two lies in the (delayed) implementation of Preface_specs.APPLICATIVE which allows, unlike Result, the accumulation of errors.
module Bifunctor : Preface_specs.BIFUNCTOR with type ('a, 'b) t = ('a, 'b) tBy setting the error type of Validation.t it is possible to get implementations for abstractions on constructors of type with an arity of 1.
module Functor
(T : Preface_specs.Types.T0) :
Preface_specs.FUNCTOR with type 'a t = ('a, T.t) tmodule Alt
(Errors : Preface_specs.SEMIGROUP) :
Preface_specs.ALT with type 'a t = ('a, Errors.t) tValidation.t implements Preface_specs.APPLICATIVE and introduces an interface to define Preface_specs.TRAVERSABLE using Validation as an iterable structure.
As you can see, it is in the definition of the Preface_specs.APPLICATIVE that Validation differs from Result. The 'errors part must be a Preface_specs.SEMIGROUP to allow for the accumulation of errors.
module Applicative
(Errors : Preface_specs.SEMIGROUP) :
Preface_specs.Traversable.API_OVER_APPLICATIVE
with type 'a t = ('a, Errors.t) tmodule Selective
(Errors : Preface_specs.SEMIGROUP) :
Preface_specs.SELECTIVE with type 'a t = ('a, Errors.t) tValidation.t implements Preface_specs.MONAD and introduces an interface to define Preface_specs.TRAVERSABLE using Validation as an iterable structure.
module Monad
(T : Preface_specs.Types.T0) :
Preface_specs.Traversable.API_OVER_MONAD with type 'a t = ('a, T.t) tmodule Foldable
(T : Preface_specs.Types.T0) :
Preface_specs.FOLDABLE with type 'a t = ('a, T.t) tmodule Invariant
(T : Preface_specs.Types.T0) :
Preface_specs.INVARIANT with type 'a t = ('a, T.t) Bifunctor.tAdditional functions to facilitate practical work with Validation.t.
val valid : 'a -> ('a, 'b) tWrap a value into Valid.
val invalid : 'b -> ('a, 'b) tWrap an error value Invalid.
val pure : 'a -> ('a, 'b) tAlias for valid.
val case : ('a -> 'c) -> ('b -> 'c) -> ('a, 'b) t -> 'ccase f g x apply f if x is Valid, g if x is Invalid.
Equality between Validation.t.
val pp :
(Stdlib.Format.formatter -> 'a -> unit) ->
(Stdlib.Format.formatter -> 'b -> unit) ->
Stdlib.Format.formatter ->
('a, 'b) t ->
unitFormatter for pretty-printing for Validation.t.