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

Maps on the two terms of an option constructor.

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

Maps over two options (e.g. v {op1} {op2})

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

Maps over three options (e.g. v {op1} {op2} {op3})

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.

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

Like package_formula, but takes the list items directly

Environment variable updates syntax

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

Innovation. Community. Security.