package pidgin

All checked builds pass
  1. Overview
  2. Docs
A common language for describing and validating data structures

Install

dune-project
 Dependency

Authors

Maintainers

Sources

pidgin-1.3.0.tbz
sha256=9f05aa80a2867cc15fabbf6d52239567d2d3b386c611dc0467c27799526e5bfc
sha512=42ae7eefe12dfba69266a1e4a19a36c7e4000a30325d222cff8f95fafb011d886b455f3aef0553c4de40d0f7d23455fdbbcca9a273a7095ca6f9d6e999e7aba7

doc/pidgin/Pidgin/Conv/index.html

Module Pidgin.ConvSource

Describes converters for lifting OCaml values into Repr.t.

Types

Sourcetype 'a t = 'a -> Repr.t

Describes a function that converts an arbitrary value to Repr.t. Since 'a is in contravariant position, 'a conv is a contravariant functor that can be used with using.

Signatures

Sourcemodule type S = Repr.PROJECTABLE

Converters

Sourceval null : 'a t
Sourceval bool : bool t

bool converter.

Sourceval int : int t

int converter.

Sourceval float : float t

float converter.

Sourceval string : string t

string converter.

Sourceval char : char t

char converter

Sourceval list : Repr.t list t

list converter.

Sourceval list_of : 'a t -> 'a list t

list_of conv l build a list of Repr.t using conv.

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

Build a record. If the flag normalize_keys is true (default value) keys are lowercased and trimmed.

Specific terms

Make use of the minimal nature of ASTs to construct more complex expressions. Mostly using records.

Sourceval option : 'a t -> 'a option t

option conv converter for option. use null for describing None and conv for Some.

Sourceval sum : ('a -> string * Repr.t) -> 'a t

sum f x produce a sum-type for a given x. The function f return a couple of constructor-name and value. The result is wrapped into the following record: {constr = "constr-name"; value = value}.

Sourceval pair : 'a t -> 'b t -> ('a * 'b) t

pair fst snd (a, b) produce a product type for a given pair a, b. The result is wrapped into the following record: {first = a; second = b}.

Sourceval result : ok:'a t -> error:'b t -> ('a, 'b) result t

result ~ok ~error is a converter for result values. It uses sum under the hood.

Sourceval either : left:'a t -> right:'b t -> ('a, 'b) Either.t t

either ~ok ~error is a converter for Either values. It uses sum under the hood.

Sourceval triple : ('a -> Repr.t) -> ('b -> Repr.t) -> ('c -> Repr.t) -> ('a * 'b * 'c) t

triple ca cb cd is a converter for triples. Under the hood, triple are pair.

Sourceval int32 : int32 t

int32 is a converter for int32. It use {constr = "int32"; value = string n} as an underlying representation.

Sourceval int64 : int64 t

int64 is a converter for int64. It use {constr = "int64"; value = string n} as an underlying representation.

Sourceval nel : Repr.t Nel.t t

Non empty list converter.

Sourceval nel_of : 'a t -> 'a Nel.t t

nel_of conv l build a non-empty-list of Repr.t using conv.

Specific converters

Sourceval into : (module S with type t = 'a) -> 'a t

into (module Proj) converts value using Proj.to_pidgin.

Mapping

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

using f conv is a contramap. If we have a function from b to a, then we can get a conversion from a to t to b to t.

Sourceval replace : 'b -> 'b t -> 'a t

replace k is using (fun _ -> k).

Infix operators

Sourcemodule Infix : sig ... end

Some infix helpers.

include module type of Infix
Sourceval (<$>) : ('b -> 'a) -> 'a t -> 'b t

f <$> conv is using f conv.