Module Pidgin.PrismSource

A Prism is used to describe a codec that enables serialization and deserialization (it consists of a Repr.conv and a Check.t pair).

Types

Sourcetype 'a t

The type that describes the pair of converter and validator.

Building prisms

Sourceval make : conv:'a Repr.conv -> check:'a Check.t -> 'a t

make ~conv ~check constructs a prism for type 'a.

Running prisms

Sourceval conv : 'a t -> 'a Repr.conv

conv prism extract the prism conversion function.

Sourceval check : 'a t -> 'a Check.t

check prism extract the prism validation function.

Helpers

A few additional tools for working with prisms.

Sourceval invmap : ('a -> 'b) -> ('b -> 'a) -> 'a t -> 'b t

invmap f g prism map both f and g on, respectively, check and conv.

Sourceval refine : ('a, 'b) Check.fn -> ('b -> 'a) -> 'a t -> 'b t

refine f g prism bind f and map g on, respectively, check and conv.