Module Type.Coded

Coded types.

type 'a repr = 'a t
type ('a, 'b) map = 'a -> ( 'b, string ) Stdlib.result

The type for partially mapping values of type 'a to values of type 'b.

type ('a, 'b) t

The type for coding values of type 'a by values of type 'b.

val v : ?pp:( Stdlib.Format.formatter -> 'a -> unit ) -> name:string -> ( 'a, 'b ) map -> ( 'b, 'a ) map -> 'b repr -> ( 'a, 'b ) t

v ~pp ~name enc dec is a coding using enc to encode values and dec to decode them. name is a name for the coded type. pp is an optional formatter.

val name : ( 'a, 'b ) t -> string

name c is c's name.

val enc : ( 'a, 'b ) t -> ( 'a, 'b ) map

enc c is c's encoder.

val dec : ( 'a, 'b ) t -> ( 'b, 'a ) map

dec c is c's decoder.

val repr : ( 'a, 'b ) t -> 'b repr

repr c is the coding target representation.

val pp : ( 'a, 'b ) t -> ( Stdlib.Format.formatter -> 'a -> unit ) option

pp c is c's pretty printer (if any).