Preface_stdlib.ValidateImplementation for Try.t.
Validate.t is a biased version of Validation with the errors fixed as an Nonempty_list of exception.
type 'a t = ('a, exn Nonempty_list.t) Validation.tValidate is a specialisation of Validation, so the module does not re-export the Validation constructors (they do not have the same arity) so if you want to pattern match a Validate value you will have to use the Validation constructors:
match validated_value with
| Validation.Valid x -> x
| Validation.Invalid errors ->
Format.sprintf "Error: %a" (Nonempty_list.pp Exn.pp) errorsmodule Functor : Preface_specs.FUNCTOR with type 'a t = 'a tmodule Alt : Preface_specs.ALT with type 'a t = 'a tValidate.t implements Preface_specs.APPLICATIVE and introduces an interface to define Preface_specs.TRAVERSABLE using Validate as an iterable structure.
As you can see, it is in the definition of the Preface_specs.APPLICATIVE that Validate differs from Try. The 'errors part must be a Preface_specs.SEMIGROUP to allow for the accumulation of errors.
module Applicative :
Preface_specs.Traversable.API_OVER_APPLICATIVE with type 'a t = 'a tmodule Selective : Preface_specs.SELECTIVE with type 'a t = 'a tValidate.t implements Preface_specs.MONAD and introduces an interface to define Preface_specs.TRAVERSABLE using Validate as an iterable structure.
module Monad : Preface_specs.Traversable.API_OVER_MONAD with type 'a t = 'a tmodule Foldable : Preface_specs.FOLDABLE with type 'a t = 'a tmodule Invariant : Preface_specs.INVARIANT with type 'a t = 'a tAdditional functions to facilitate practical work with Validate.t.
val pure : 'a -> 'a tCreate a value from 'a to 'a t.
val valid : 'a -> 'a tWrap a value into Valid.
val invalid : exn Nonempty_list.t -> 'a tWrap an exception list into Invalid.
val error : exn -> 'a tWrap an exception into a list and wrap the list into Invalid.
val case : ('a -> 'b) -> (exn Nonempty_list.t -> 'b) -> 'a t -> 'bcase f g x apply f if x is Valid, g if x is Invalid.
val to_result : 'a t -> ('a, exn Nonempty_list.t) Stdlib.resultProject a Validate into a Result.
val pp :
(Stdlib.Format.formatter -> 'a -> unit) ->
Stdlib.Format.formatter ->
'a t ->
unitFormatter for pretty-printing for Validate.t.