package yocaml

  1. Overview
  2. Docs
Core engine of the YOCaml Static Site Generator

Install

Dune Dependency

Authors

Maintainers

Sources

yocaml-2.3.0.tbz
sha256=216c47d4d954a1e210437101a46736a09fb2e198baf12657c13ade8f24aab7cb
sha512=3bef1e6e93644f860d5b4e72b392530eb0d5ba0ae2cabe198b85b90b92cfd2ad19ff0416d77d46760bcd63b9561c409ef1ecfb11ccacef8e474e7a231234b623

doc/yocaml/Yocaml/Data/index.html

Module Yocaml.DataSource

Describes an mostly compatible Ezjsonm AST that acts as a generic AST for describing metadata that can be exchanged between source documents and templates. To summarise, source metadata is ultimately projected into a value of type Yocaml.Data.t and data injected into templates is projected from values of type Yocaml.Data.t.

To be generic, you need to provide a module capable of transforming the AST of arbitrary metadata (for example, Yaml) into a value of type Yocaml.Data.t to be used generically.

Types

Sourcetype t = private
  1. | Null
  2. | Bool of bool
  3. | Int of int
  4. | Float of float
  5. | String of string
  6. | List of t list
  7. | Record of (string * t) list
    (*

    Describes the set of possible values for the Data AST.

    *)
Sourcetype ezjsonm = [
  1. | `Null
  2. | `Bool of bool
  3. | `Float of float
  4. | `String of string
  5. | `A of ezjsonm list
  6. | `O of (string * ezjsonm) list
]

Describes type ezjsonm (to be compatible with historical libraries, such as ocaml_yaml).

Creating Data values

Sourceval null : t

null returns the t for null.

Sourceval bool : bool -> t

bool b converts a Boolean into a t.

Sourceval int : int -> t

int i converts an integer into a t.

Sourceval float : float -> t

float f converts a float into a t.

Sourceval string : string -> t

string s converts a string into a t.

Sourceval list : t list -> t

list v converts a list of t into a t.

Generic Data values

Building generic Data values.

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

list f v converts a list of arbitrary values into a t.

Sourceval record : (string * t) list -> t

record fields converts a list of t into a t.

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

option opt converts an option into a t or null.

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

sum f x convert sum into a t.

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

pair f g (x, y) construct a pair as a t. A pair has the structure {"fst": a, "snd": b}.

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

triple f g h (x, y, z) is pair f (pair g h) (x, (y, z)). It use pair to define triple.

Sourceval quad : ('a -> t) -> ('b -> t) -> ('c -> t) -> ('d -> t) -> ('a * 'b * 'c * 'd) -> t

quad f g h i (w, x, y, z) is pair f (triple g h) (w, (x, y, z))

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

either f g x construct either as a t. Either has the structure {"constr": "left | right", "value": e}.

Validating Data values

Sourcemodule Validation : sig ... end

Used to validate data described by type Yocaml.Data.t to build validation pipelines. The aim of this module is to produce combinators for building validation pipelines that support nesting and that can transform any value described by the AST in Data into arbitrary OCaml values.

Utils

Sourceval equal : t -> t -> bool

Equality between t.

Sourceval pp : Format.formatter -> t -> unit

Pretty-printer for t (mostly used for debugging issue).

Sourceval to_ezjsonm : t -> ezjsonm

to_ezjsonm v converts a t into a ezjsonm.

Sourceval from_ezjsonm : ezjsonm -> t

from_ezjsonm v converts a ezjsonm into a t.

OCaml

Innovation. Community. Security.