Module Private.Codec
Topkg interprocess communication codec.
Codecs for communication between the topkg tool and topkg description files.
Decode errors
type error=|Corrupted of string * string|Version of int * intThe type for decode errors.
Corrupted (kind, data), an error occured while decodingdataforkind.Version (exp, fnd), a versioned decoder expected versionexpbut foundfnd
val pp_error : Stdlib.Format.formatter -> error -> unitpp_error ppf eprints an unspecified representation ofeonppf.
exceptionError of errorRaised on decode errors.
Codecs
val v : kind:string -> enc:('a -> string) -> dec:(string -> 'a) -> 'a tv kind enc decis a codec for value identified askindusingencto encode anddecto decode.
val kind : 'a t -> stringkind cisc's kind.
val enc : 'a t -> 'a -> stringenc cisc's encoder.
val dec : 'a t -> string -> 'adec cisc's decoder. The decoder- raises Error
in case of decode error
Base type codecs
val unit : unit tunitcodecs a().
val const : 'a -> 'a tconst vcodecs the constantv.
val bool : bool tboolcodecs booleans.
val int : int tintcodecs integers.
val string : string tstringcodecs strings.
val result : ok:'a t -> error:'b t -> ('a, 'b) Result.result tresult ~ok ~errorcodecsok,errorresults.
val t5 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> ('a * 'b * 'c * 'd * 'e) tt5is likepairbut for qintuples.
val alt : kind:string -> ('a -> int) -> 'a t array -> 'a talt tag cscodecs values by tagging them withtagand using the corresponding codec incs.- raises Invalid_argument
if
Array.length cs > 256.
Topkg types
val msg : [ `Msg of string ] tmsgcodecs error messages.