package jsont

  1. Overview
  2. Docs

Case objects.

Case objects are used to describe objects whose members depend on the tag value of a distinguished case member. See an example.

Maps

type 'a jsont := 'a t
type ('cases, 'case, 'tag) map

The type for mapping a case object represented by 'case belonging to a common type represented by 'cases depending on the value of a case member of type 'tag.

val map : ?dec:('case -> 'cases) -> 'tag -> 'case jsont -> ('cases, 'case, 'tag) map

map ~dec v obj defines the object map obj as being the case for the tag value v of the case member. dec indicates how to inject the object case into the type common to all cases.

Raises Invalid_argument if obj is not a direct result of finish, that is if obj does not describe an object.

Cases

type ('cases, 'tag) t

The type for a case of the type 'cases. This is map with its 'case representation hidden.

val make : ('cases, 'case, 'tag) map -> ('cases, 'tag) t

make map is map as a case.

Case values

type ('cases, 'tag) value

The type for case values. This holds a case value and its case map map. Use value to construct them.

val value : ('cases, 'case, 'tag) map -> 'case -> ('cases, 'tag) value

value map v is a case value v described by map.

OCaml

Innovation. Community. Security.