sidekick/src/util/ser_decode.mli
Simon Cruanes 7b4404fb78
feat(tracing): introduce term/const serialization
- use a record instead of 1st class module for `Const.ops`, so it
  can be mutually recursive with the definition of `term`
- remove unused `Const.ops.opaque_to_cc`
- constants are serializable using `Ser_value`
2022-09-23 22:13:21 -04:00

46 lines
1.1 KiB
OCaml

(** Decoders for {!Ser_value}.
Combinators to decode values. *)
type +'a t
(** Decode a value of type ['a] *)
val int : int t
val bool : bool t
val string : string t
val return : 'a -> 'a t
val fail : string -> 'a t
val unwrap_opt : string -> 'a option -> 'a t
(** Unwrap option, or fail *)
val any : Ser_value.t t
val list : 'a t -> 'a list t
val dict_field : string -> 'a t -> 'a t
val dict_field_opt : string -> 'a t -> 'a option t
val both : 'a t -> 'b t -> ('a * 'b) t
val try_l : 'a t list -> 'a t
module Infix : sig
val ( >|= ) : 'a t -> ('a -> 'b) -> 'b t
val ( >>= ) : 'a t -> ('a -> 'b t) -> 'b t
val ( let+ ) : 'a t -> ('a -> 'b) -> 'b t
val ( and+ ) : 'a t -> 'b t -> ('a * 'b) t
val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t
val ( and* ) : 'a t -> 'b t -> ('a * 'b) t
end
include module type of Infix
(** {2 Deserializing} *)
module Error : sig
type t
include Sidekick_sigs.PRINT with type t := t
val to_string : t -> string
end
val run : 'a t -> Ser_value.t -> ('a, Error.t) result
val run_exn : 'a t -> Ser_value.t -> 'a
(** @raise Error.Error in case of failure *)