package opam-lib

  1. Overview
  2. Docs
On This Page
  1. Atoms
Legend:
Library
Module
Module type
Parameter
Class
Class type

Management of formulas

type relop = [
  1. | `Eq
  2. | `Neq
  3. | `Geq
  4. | `Gt
  5. | `Leq
  6. | `Lt
]

binary operations (compatible with the Dose type for Cudf operators !)

val string_of_relop : relop -> string

Pretty-printing of relops

val relop_of_string : string -> relop

Parsing relops

type version_constraint = relop * OpamPackage.Version.t

Version constraints for OPAM

Formula atoms for OPAM

val string_of_atom : atom -> string

Pretty-printing of atoms

val short_string_of_atom : atom -> string

The compact atom format used in requests, "pkgOPvers", with '.' allowed instead of '='

val string_of_atoms : atom list -> string

Prints atoms as a conjunction ("&") using the short format

val check : atom -> OpamPackage.t -> bool

Checks if a package verifies an atom

type 'a conjunction = 'a list

AND formulas

val string_of_conjunction : ('a -> string) -> 'a conjunction -> string

Pretty print AND formulas

type 'a disjunction = 'a list

OR formulas

val string_of_disjunction : ('a -> string) -> 'a disjunction -> string

Pretty print OR formulas

type 'a cnf = 'a disjunction conjunction

CNF formulas (Conjunctive Normal Form)

type 'a dnf = 'a conjunction disjunction

DNF formulas (Disjunctive Normal Form)

val string_of_cnf : ('a -> string) -> 'a cnf -> string

Pretty print CNF formulas

val string_of_dnf : ('a -> string) -> 'a dnf -> string

Pretty print DNF formulas

type 'a formula =
  1. | Empty
  2. | Atom of 'a
  3. | Block of 'a formula
  4. | And of 'a formula * 'a formula
  5. | Or of 'a formula * 'a formula

General formulas

val eval : ('a -> bool) -> 'a formula -> bool

Eval a formula

val check_relop : relop -> int -> bool

Check a relational operator against an integer from compare

val eval_relop : relop -> OpamPackage.Version.t -> OpamPackage.Version.t -> bool

Evaluate a relational operator between versions

val neg_relop : relop -> relop
val string_of_formula : ('a -> string) -> 'a formula -> string

Pretty print a formula

val ands : 'a formula list -> 'a formula

Convert a list of formulas to an AND-formula (Empty formulas are ignored)

val ands_to_list : 'a formula -> 'a formula list

Converts back an AND-formula to a list (flattens top-level ands)

val ors : 'a formula list -> 'a formula

Convert a list of formulas to an OR-formula (Empty formulas are ignored)

val ors_to_list : 'a formula -> 'a formula list

Converts back an OR-formula to a list (flattens top-level ors)

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

Map on atoms. Atoms for which the given function returns Empty will be simply removed

val map_formula : ('a formula -> 'a formula) -> 'a formula -> 'a formula

Maps top-down on a formula

val neg : ('a -> 'a) -> 'a formula -> 'a formula

Negates a formula (given the function to negate atoms)

val iter : ('a -> unit) -> 'a formula -> unit

Iter function

val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b formula -> 'a

Fold function

type version_formula = version_constraint formula

Expressions composed entirely of version constraints

An atom is: name * (relop * version) formula. Examples of valid formulae:

  • "foo" {> "1" & (<"3" | ="5")}
  • "foo" {= "1" | > "4"} | ("bar" "bouh")
val cnf_of_formula : 'a formula -> 'a formula

Convert a formula to CNF

val dnf_of_formula : 'a formula -> 'a formula

Convert a formula to DNF

val to_atom_formula : t -> atom formula

Transform a formula where versions can be expressed using formulas to a flat atom formula

val of_atom_formula : atom formula -> t

Convert an atom-formula to a t-formula

val simplify_version_formula : version_formula -> version_formula

Reduces the formula, finding a shorter description of the same version set. Keeps conflicting formula, for documentation, when the set is empty.

Atoms

val atoms : t -> atom list

Return all the atoms

val to_string : t -> string

Pretty print the formula

val to_conjunction : t -> atom conjunction

Return a conjunction. If the initial formula is not a conjunction, then fail.

val of_conjunction : atom conjunction -> t

Return a formula from a conjunction of atoms

val to_disjunction : t -> atom disjunction

Return a disjunction. It the initial formula is not a disjunction, then fail.

val of_disjunction : atom disjunction -> t

Return a formula from a disjunction of atoms

val to_cnf : t -> atom cnf

Return an equivalent CNF formula

val to_dnf : t -> atom dnf

Return an equivalent DNF formula

type 'a ext_package_formula = (OpamPackage.Name.t * ('a * version_formula)) formula

Formula over versionned packages with additional flags (used to handle eg. build-deps)

val formula_of_extended : filter:('a -> bool) -> 'a ext_package_formula -> t

Turns an extended package formula to a normal formula, by filtering out the packages on the flags of which filter returns false.

OCaml

Innovation. Community. Security.