Module Core_kernel__Validated_intf
For making an abstract version of a type that ensures a validation check has passed.
Suppose one wants to have a type of positive integers:
module Positive_int = Validated.Make (struct
type t = int
let here = [%here]
let validate = Int.validate_positive
end)
With this, one is certain that any value of type Positive_int.t
has passed Int.validate_positive
.
One can call Positive_int.create_exn n
to create a new positive int from an n
, which will of course raise if n <= 0
. One can call Positive_int.raw positive_int
to get the int
from a Positive_int.t
.
module type Raw = sig ... end
module type Raw_bin_io = sig ... end
module type Raw_bin_io_compare_hash_sexp = sig ... end
module type S = sig ... end
module type S_bin_io = sig ... end
module type S_bin_io_compare_hash_sexp = sig ... end
module type Validated = sig ... end