package opam-format

  1. Overview
  2. Docs

These base converters raise Unexpected when not run on the right input (which is then converted to Bad_format by the parser.

val bool : (OpamTypes.value, bool) OpamPp.t
val int : (OpamTypes.value, int) OpamPp.t
val pos_int : (OpamTypes.value, int) OpamPp.t

positive or null integer

val ident : (OpamTypes.value, string) OpamPp.t
val string : (OpamTypes.value, string) OpamPp.t
val string_tr : (OpamTypes.value, string) OpamPp.t

Trimmed string

Command arguments, i.e. strings or idents

Strings or bools

"a b c"; also allows just "a" to be parsed as a singleton list

"(a b c)"

Options in the value type sense, i.e. a value with an optional list of parameters in braces: "value op1 op2"

val map_group : (OpamTypes.value, 'a) OpamPp.t -> (OpamTypes.value, 'a list) OpamPp.t
val map_list : ?depth:int -> (OpamTypes.value, 'a) OpamPp.t -> (OpamTypes.value, 'a list) OpamPp.t

An expected list depth may be specified to enable removal of extra brackets (never use ~depth for an inner list)

val list_depth : int -> (OpamTypes.value, OpamTypes.value) OpamPp.t

Normalises to the given list depth when parsing, and removes brackets that can be made implicit when printing

val map_option : (OpamTypes.value, 'a) OpamPp.t -> (OpamTypes.value list, 'b) OpamPp.t -> (OpamTypes.value, 'a * 'b) OpamPp.t
val map_pair : (OpamTypes.value, 'a) OpamPp.t -> (OpamTypes.value, 'b) OpamPp.t -> (OpamTypes.value, 'a * 'b) OpamPp.t

A pair is simply a list with two elements in the value type

val map_triple : (OpamTypes.value, 'a) OpamPp.t -> (OpamTypes.value, 'b) OpamPp.t -> (OpamTypes.value, 'c) OpamPp.t -> (OpamTypes.value, 'a * 'b * 'c) OpamPp.t

A triple is simply a list with three elements in the value type

Specialised url parser when the backend is already known

val compiler_version : (OpamTypes.value, string) OpamPp.t
val filter_ident : (OpamTypes.value, OpamTypes.name option list * OpamTypes.variable * (string * string) option) OpamPp.t

Arguments in commands (term + optional filter)

Simple dependency constraints

val filtered_constraints : (OpamTypes.value, 'version) OpamPp.t -> (OpamTypes.value list, 'version OpamTypes.filter_or_constraint OpamFormula.formula) OpamPp.t

Dependency constraints mixed with filters

Package versions

Package versions as filters, as they may appear in dependency (may be an expanded string or an ident)

A package name, encoded as a string, but with restrictions

val package_atom : (OpamTypes.value list, 'a) OpamPp.t -> (OpamTypes.value, OpamTypes.name * 'a) OpamPp.t

Returns an atom parser ("package" {>= "version"}) from a constraint and a version parser

val package_formula : [< `Conj | `Disj ] -> (OpamTypes.value list, 'a) OpamPp.t -> (OpamTypes.value, (OpamTypes.name * 'a) OpamFormula.formula) OpamPp.t

Takes a parser for constraints. Lists without operator will be understood as conjunctions or disjunctions depending on the first argument.

Environment variable updates syntax

val features : (OpamTypes.value, (OpamTypes.variable * string * OpamTypes.filter) list) OpamPp.t

For the "features" field, e.g. a list of (variable "doc" {filter})

val os_constraint : (OpamTypes.value, (bool * string) OpamFormula.formula) OpamPp.t
OCaml

Innovation. Community. Security.