package opam-lib

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Format of OPAM configuration files.

val empty : OpamTypes.file

The empty file

val map : (string -> OpamTypes.value -> (string * OpamTypes.value) option) -> OpamTypes.file -> OpamTypes.file

map a file

val variables : OpamTypes.file_item list -> (string * OpamTypes.value) list

Get all the variable definitions from a list of items

val sections : OpamTypes.file_item list -> (string * OpamTypes.file_section) list

Get all the sections from a list of items

val is_valid : ?allow_extended:bool -> OpamTypes.file_item list -> string list -> bool

Check whether a list of items contains only valid variable definitions.

val invalid_fields : ?allow_extended:bool -> OpamTypes.file_item list -> string list -> string list

Find all the invalid fields. If allow_extended is specified and true, fields starting with "x-" are not reported

Parsing functions

exception Bad_format of OpamTypes.pos option * string list * string

All the following parsing function raise Bad_format in case the input does not have the right format.

val bad_format : ?pos:OpamTypes.pos -> ('a, unit, string, 'b) Stdlib.format4 -> 'a

Raise Bad_format.

val string_of_bad_format : ?file:OpamTypes.filename -> exn -> string
val add_pos : OpamTypes.pos -> exn -> exn

Adds a position to a Bad_format exception if it doesn't have one yet

val value_pos : OpamTypes.value -> OpamTypes.pos

Get the position out of a value

val values_pos : OpamTypes.value list -> OpamTypes.pos option

Get the position of the first element out of a value list

val parse_bool : OpamTypes.value -> bool

Parse a boolean

val parse_int : OpamTypes.value -> int

Parse an integer

val parse_ident : OpamTypes.value -> string

Parse an ident

val parse_string : OpamTypes.value -> string

Parse a string

val parse_list : (OpamTypes.value -> 'a) -> OpamTypes.value -> 'a list

Parse a list of 'things'

val parse_list_list : (OpamTypes.value -> 'a) -> OpamTypes.value -> 'a list

Parse a list of list of 'things'

val parse_group : (OpamTypes.value -> 'a) -> OpamTypes.value -> 'a list

Parse a group of 'things'

val parse_option : (OpamTypes.value -> 'a) -> (OpamTypes.value list -> 'b) -> OpamTypes.value -> 'a * 'b option

Parse a value and its option of 'things'

val parse_single_option : (OpamTypes.value -> 'a) -> (OpamTypes.value -> 'b) -> OpamTypes.value -> 'a * 'b option

Parse a value and a single optional value

val parse_string_option : (OpamTypes.value list -> 'a) -> OpamTypes.value -> string * 'a option

Parse a string with an optional argument

val parse_string_list : OpamTypes.value -> string list

Parse a list of strings

val parse_single_string : OpamTypes.value list -> string

Parse a single string

val parse_pair : (OpamTypes.value -> 'a) -> (OpamTypes.value -> 'b) -> OpamTypes.value -> 'a * 'b

Parse a pair of strings

val parse_or : (string * (OpamTypes.value -> 'a)) list -> OpamTypes.value -> 'a

Try to parse the value using function from the list. All the parsing functions are tried until one succeeds. The first argument is a debug message.

Creation functions

val make_bool : bool -> OpamTypes.value

Create a boolean

val make_int : int -> OpamTypes.value

Create an integer

val make_ident : string -> OpamTypes.value

Create an ident

val make_string : string -> OpamTypes.value

Create a string

val make_list : ('a -> OpamTypes.value) -> 'a list -> OpamTypes.value

Create a list of 'things'

val make_string_list : string list -> OpamTypes.value

Create a list of strings

val make_group : ('a -> OpamTypes.value) -> 'a list -> OpamTypes.value

Create a group of 'things'

val make_option : ('a -> OpamTypes.value) -> ('b -> OpamTypes.value list) -> ('a * 'b option) -> OpamTypes.value

Create a value and its optional arguments

val make_pair : ('a -> OpamTypes.value) -> ('b -> OpamTypes.value) -> ('a * 'b) -> OpamTypes.value

Create a pair

val make_string_pair : (string * string) -> OpamTypes.value

Create a pair of strings

Create a file section

val make_variable : (string * OpamTypes.value) -> OpamTypes.file_item

Create a variable

Printing functions

val string_of_value : OpamTypes.value -> string

Print a value

val string_of_values : OpamTypes.value list -> string

Print a list of values

val string_of_file : simplify:bool -> OpamTypes.file -> string

Print a file

Finding functions

val assoc : OpamTypes.file_item list -> string -> (OpamTypes.value -> 'a) -> 'a

Get the value of a field

val assoc_option : OpamTypes.file_item list -> string -> (OpamTypes.value -> 'a) -> 'a option

Get the value of a field. If the field does not exist, return None

val assoc_default : 'a -> OpamTypes.file_item list -> string -> (OpamTypes.value -> 'a) -> 'a

Get the value of a field. If the variable does not exist, return a default value

val assoc_list : OpamTypes.file_item list -> string -> (OpamTypes.value -> 'a list) -> 'a list

Get the value associated to a variable. If the variable does not exists, return

val assoc_string_list : OpamTypes.file_item list -> string -> string list

Get the string list associated to a variable. If the variable does not exist, return

val get_section_by_kind : OpamTypes.file_item list -> string -> OpamTypes.file_section

Get one section of a certain kind

val get_all_section_by_kind : OpamTypes.file_item list -> string -> OpamTypes.file_section list

Get all the sections of a certain kind

val assoc_sections : OpamTypes.file_item list -> string -> (OpamTypes.file_section -> 'a) -> 'a list

Get sections

Formula

This section is dedicated to the parsing and creatin of dependency and conflict formaulas. It's maybe easier to do that directly in the parser ...

val parse_package_name : ?expected:OpamTypes.name -> OpamTypes.value -> OpamTypes.name
val parse_package_version : ?expected:OpamTypes.version -> OpamTypes.value -> OpamTypes.version
val parse_constraints : OpamTypes.value list -> OpamFormula.version_formula

Parser for version constraints in formulas

Parser for version constraints in formula with dependency flags

val make_constraints : OpamFormula.version_formula -> OpamTypes.value list

Builder for version constraints in formulas

val make_ext_constraints : (OpamTypes.package_dep_flag list * OpamFormula.version_formula) -> OpamTypes.value list

Builder for version constraints in formula with dependency flags

val parse_formula : [ `Conj | `Disj ] -> (OpamTypes.value list -> 'a) -> OpamTypes.value -> (OpamTypes.name * 'a) OpamTypes.generic_formula

Parse package formula as a `Conjunction or `Disjunction, using the given parser for constraints

val make_formula : [ `Conj | `Disj ] -> ('a -> OpamTypes.value list) -> (OpamTypes.name * 'a) OpamTypes.generic_formula -> OpamTypes.value

Build a formula as a `Conjunction or `Disjunction, building constraints with the given function

val parse_compiler_version : OpamTypes.value -> OpamTypes.compiler_version

Parse compiler versions

val parse_compiler_constraint : OpamTypes.value -> OpamTypes.compiler_constraint

Parse compiler constraints

val make_compiler_constraint : OpamTypes.compiler_constraint -> OpamTypes.value

Build a compiler constraint

val parse_os_constraint : OpamTypes.value -> (bool * string) OpamTypes.generic_formula

Parse an OS constraint

val make_os_constraint : (bool * string) OpamTypes.generic_formula -> OpamTypes.value

Build an OS constraint

Environment variables

val parse_env_variable : OpamTypes.value -> string * string * string

Parsing

val make_env_variable : (string * string * string) -> OpamTypes.value

Making

filter expressions

val parse_filter : OpamTypes.value list -> OpamTypes.filter

Parsing

val make_filter : OpamTypes.filter -> OpamTypes.value list

Creation

val parse_single_command : OpamTypes.value -> OpamTypes.arg list

Unfiltered argument list

val make_single_command : OpamTypes.arg list -> OpamTypes.value
val parse_command : OpamTypes.value -> OpamTypes.command

Parse a command

val make_command : OpamTypes.command -> OpamTypes.value

Create a command

val parse_commands : OpamTypes.value -> OpamTypes.command list

Parse a list of commands

val make_commands : OpamTypes.command list -> OpamTypes.value

Create a list of commands

val parse_messages : OpamTypes.value -> (string * OpamTypes.filter option) list

Parse a list of commands

val make_libraries : (string * OpamTypes.filter option) list -> OpamTypes.value

Create a list of libraries/syntax

val parse_libraries : OpamTypes.value -> (string * OpamTypes.filter option) list

Parse a list of libraries/syntax

Create a package flag

Parse a package flag

Tags

val parse_tags : OpamTypes.value -> OpamTypes.tags

Parse tags

val make_tags : OpamTypes.tags -> OpamTypes.value

Make tags

Features

val parse_features : OpamTypes.value -> (OpamVariable.t * string * OpamTypes.filter) list

Parse features list

val make_features : (OpamVariable.t * string * OpamTypes.filter) list -> OpamTypes.value

Make features list

OCaml

Innovation. Community. Security.