package tezos-micheline

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type annot = string list
type ('l, 'p) node =
  1. | Int of 'l * Z.t
  2. | String of 'l * string
  3. | Bytes of 'l * Bytes.t
  4. | Prim of 'l * 'p * ('l, 'p) node list * annot
  5. | Seq of 'l * ('l, 'p) node list

The abstract syntax tree of Micheline expressions. The first parameter is used to contain locations, but can also embed custom data. The second parameter is the type of primitive names.

val table_encoding : variant:string -> 'l Data_encoding.encoding -> 'p Data_encoding.encoding -> ('l, 'p) node Data_encoding.encoding

Encoding for expressions, as their canonical encoding. Locations are stored in a side table. See canonical_encoding for the variant parameter.

val erased_encoding : variant:string -> 'l -> 'p Data_encoding.encoding -> ('l, 'p) node Data_encoding.encoding

Encoding for expressions, as their canonical encoding. Locations are erased when serialized, and restored to a provided default value when deserialized. See canonical_encoding for the variant parameter.

val location : ('l, 'p) node -> 'l

Extract the location of the node.

val annotations : ('l, 'p) node -> string list

Extract the annotations of the node.

type 'p canonical

Expression form using canonical integer numbering as locations. The root has number zero, and each node adds one in the order of infix traversal. To be used when locations are not important, or when one wants to attach properties to nodes in an expression without rewriting it (using an indirection table with canonical locations as keys).

type canonical_location = int

Canonical integer locations that appear inside canonical expressions.

val canonical_location_encoding : canonical_location Data_encoding.encoding

Encoding for canonical integer locations.

val canonical_encoding : variant:string -> 'l Data_encoding.encoding -> 'l canonical Data_encoding.encoding

Encoding for expressions in canonical form. The first parameter is a name used to produce named definitions in the schemas. Make sure to use different names if two expression variants with different primitive encodings are used in the same schema.

val canonical_encoding_v0 : variant:string -> 'l Data_encoding.encoding -> 'l canonical Data_encoding.encoding

Old version of canonical_encoding for backward compatibility. Do not use in new code.

val canonical_encoding_v1 : variant:string -> 'l Data_encoding.encoding -> 'l canonical Data_encoding.encoding
val strip_locations : (_, 'p) node -> 'p canonical

Compute the canonical form of an expression. Drops the concrete locations completely.

val root : 'p canonical -> (canonical_location, 'p) node

Give the root node of an expression in canonical form.

val extract_locations : ('l, 'p) node -> 'p canonical * (canonical_location * 'l) list

Compute the canonical form of an expression. Saves the concrete locations in an association list.

val inject_locations : (canonical_location -> 'l) -> 'p canonical -> ('l, 'p) node

Transforms an expression in canonical form into a polymorphic one. Takes a mapping function to inject the concrete locations.

val map : ('a -> 'b) -> 'a canonical -> 'b canonical

Copies the tree, updating its primitives.

val map_node : ('la -> 'lb) -> ('pa -> 'pb) -> ('la, 'pa) node -> ('lb, 'pb) node

Copies the tree, updating its primitives and locations.

OCaml

Innovation. Community. Security.