package pidgin

  1. Overview
  2. Docs
A common language for describing and validating data structures

Install

dune-project
 Dependency

Authors

Maintainers

Sources

pidgin-1.0.0.tbz
sha256=4a7bb0fccdebf5b205d2eeaa8a9b8e50acf267445f949a2b1a8304def9a38548
sha512=2612fc5cbdd6173a0676ae8840158b85358744561245d0b55ce0ebcf41acb26eddbd316be42a60d55e187928182f681cf3efb4f556ddf47d698217e8376633d3

doc/pidgin/Pidgin/Kind/index.html

Module Pidgin.KindSource

A Kind is a type of light type. It holds less information than a full-fledged type system and is used primarily for generating error messages (and perhaps, in the near future, for defunctionalize validation functions). Naively, they can be viewed as a representation that does not hold the value of a term described by Repr.t.

Even though the API is user-facing, it's best to build validators that allow users to ignore it.

Types

Sourcetype t = private
  1. | Any
  2. | Or of t list
  3. | Null
  4. | Bool
  5. | Int
  6. | Float
  7. | String
  8. | List of t
  9. | Branch of string * t
  10. | Pair of t * t
  11. | Record of (string * t) list

The type describing a Kind. Unlike representations, a user does not want to manipulate them explicitly, which is why they remain private. (Not abstract for inspection)

Inference/Deduction

Sourceval infer : Repr.t -> t

infer repr deduce the kind of the given repr.

Building kinds

For validation function, we want to be able to create kinds for error reporting. (Remember that kinds are mapped to Repr.t)

Sourceval any : t

Describe the sad any kind. When a value is not unifiable or inferable.

Sourceval null : t

Describe the kind for Repr.null.

Sourceval bool : t

Describe the kind for Repr.bool.

Sourceval int : t

Describe the kind for Repr.int.

Sourceval float : t

Describe the kind for Repr.float.

Sourceval string : t

Describe the kind for Repr.string.

Sourceval list : t -> t

Describe the kind for Repr.list.

Sourceval record : ?normalize_keys:bool -> (string * t) list -> t

Describe the kind for Repr.record.

Sourceval or_ : t -> t -> t

Describe an union of kind.

Sourceval unify : t Nel.t -> t

Reduce a list of kind one kind, using or_.

Sourceval branch : string -> t -> t

Describe a branch.

Sourceval sum : (string * t) Nel.t -> t

Describe a sum type using or_.

Sourceval pair : t -> t -> t

Describe a special kind for pair.

Sourceval tuple : t Nel.t -> t

Build a tuple, if there is one value, it return it, otherwise it build a pair (possibly of pairs). Non Tail-recursive.

Sourceval triple : t -> t -> t -> t

triple a b c is pair a (pair b c).

Equality and comparison

Sourceval equal : t -> t -> bool

Equality between kinds.

Sourceval compare : t -> t -> int

Comparison between kinds.

Misc

Sourceval to_string : t -> string

to_string kind dump the given kind in a readdable way.