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 : (OpamParserTypes.FullPos.value, bool) OpamPp.t
val int : (OpamParserTypes.FullPos.value, int) OpamPp.t
val pos_int : (OpamParserTypes.FullPos.value, int) OpamPp.t

positive or null integer

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

Trimmed string

val simple_arg : (OpamParserTypes.FullPos.value, OpamTypes.simple_arg) OpamPp.t

Command arguments, i.e. strings or idents

val variable_contents : (OpamParserTypes.FullPos.value, OpamTypes.variable_contents) OpamPp.t

Strings or bools

val list : (OpamParserTypes.FullPos.value, OpamParserTypes.FullPos.value list) OpamPp.t

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

val group : (OpamParserTypes.FullPos.value, OpamParserTypes.FullPos.value list) OpamPp.t

"(a b c)"

val option : (OpamParserTypes.FullPos.value, OpamParserTypes.FullPos.value * OpamParserTypes.FullPos.value list) OpamPp.t

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

val map_group : (OpamParserTypes.FullPos.value, 'a) OpamPp.t -> (OpamParserTypes.FullPos.value, 'a list) OpamPp.t
val map_list : ?depth:int -> (OpamParserTypes.FullPos.value, 'a) OpamPp.t -> (OpamParserTypes.FullPos.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 -> (OpamParserTypes.FullPos.value, OpamParserTypes.FullPos.value) OpamPp.t

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

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

Maps on the two terms of an option constructor.

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

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

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

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

val map_pair : (OpamParserTypes.FullPos.value, 'a) OpamPp.t -> (OpamParserTypes.FullPos.value, 'b) OpamPp.t -> (OpamParserTypes.FullPos.value, 'a * 'b) OpamPp.t

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

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

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

val url : (OpamParserTypes.FullPos.value, OpamTypes.url) OpamPp.t
val url_with_backend : OpamUrl.backend -> (OpamParserTypes.FullPos.value, OpamTypes.url) OpamPp.t

Specialised url parser when the backend is already known

val compiler_version : (OpamParserTypes.FullPos.value, string) OpamPp.t
val filter_ident : (OpamParserTypes.FullPos.value, OpamTypes.name option list * OpamTypes.variable * (string * string) option) OpamPp.t
val filter : (OpamParserTypes.FullPos.value list, OpamTypes.filter) OpamPp.t
val arg : (OpamParserTypes.FullPos.value, OpamTypes.simple_arg * OpamTypes.filter option) OpamPp.t

Arguments in commands (term + optional filter)

val command : (OpamParserTypes.FullPos.value, (OpamTypes.simple_arg * OpamTypes.filter option) list * OpamTypes.filter option) OpamPp.t
val constraints : (OpamParserTypes.FullPos.value, 'a) OpamPp.t -> (OpamParserTypes.FullPos.value list, (OpamFormula.relop * 'a) OpamFormula.formula) OpamPp.t

Simple dependency constraints

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

Dependency constraints mixed with filters

val version : (OpamParserTypes.FullPos.value, OpamTypes.version) OpamPp.t

Package versions

val ext_version : (OpamParserTypes.FullPos.value, OpamTypes.filter) OpamPp.t

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

val pkgname : (OpamParserTypes.FullPos.value, OpamTypes.name) OpamPp.t

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

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

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

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

Like package_formula, but takes the list items directly

val formula_items : name:string -> [< `Conj | `Disj ] -> ?only:[ `And | `Or ] -> (OpamParserTypes.FullPos.value, 'a) OpamPp.t -> (OpamParserTypes.FullPos.value list, 'b) OpamPp.t -> (OpamParserTypes.FullPos.value list, ('a * 'b) OpamFormula.formula) OpamPp.t

Generic package_formula_items pp

val separator : (OpamParserTypes.FullPos.value, OpamTypes.separator) OpamPp.t

Environment variable updates syntax

val path_format : (OpamParserTypes.FullPos.value, OpamTypes.path_format) OpamPp.t
val env_binding : (OpamParserTypes.FullPos.value, (OpamTypes.spf_resolved, OpamTypes.euok_writeable) OpamTypes.env_update) OpamPp.t
val env_binding_unresolved : (OpamParserTypes.FullPos.value, (OpamTypes.spf_unresolved, OpamTypes.euok_writeable) OpamTypes.env_update) OpamPp.t
val os_constraint : (OpamParserTypes.FullPos.value, (bool * string) OpamFormula.formula) OpamPp.t
OCaml

Innovation. Community. Security.