package mirage

  1. Overview
  2. Docs

Module Functoria.KeySource

Configuration command-line arguments.

Sourcemodule Arg : sig ... end

Terms for cross-stage arguments.

Configuration Keys

Sourcetype 'a key

The type for configuration keys. Keys are used to parameterize the choice of module implementation.

Sourceval create : string -> 'a Arg.t -> 'a key

create n a is the key named n whose contents is determined by parsing the command-line argument a.

Configuration Values

Sourcetype +'a value

The type for configure-time and run-time values. Values are either pure or obtained by composing other values. Values might have data dependencies, which form an (implicit) directed and acyclic graph that need to be evaluated.

Sourceval pure : 'a -> 'a value

pure x is a value without any dependency.

Sourceval ($) : ('a -> 'b) value -> 'a value -> 'b value

f $ v is is the value resulting from the application of f'value to v's value. $ is the usual app operator for applicative functor.

Sourceval map : ('a -> 'b) -> 'a value -> 'b value

map f v is pure f $ v.

Sourceval if_ : bool value -> 'a -> 'a -> 'a value

if_ v x y is map (fun b -> if b then x else y) v.

Sourceval match_ : 'a value -> ('a -> 'b) -> 'b value

match_ v pattern is map pattern v.

Sourceval default : 'a value -> 'a

default v returns the default value for v.

Sourceval value : 'a key -> 'a value

value k is the value parsed by k.

Abstract Keys

Sourcetype t

The type for abstract keys.

Sourceval name : t -> string

name t is the string given as t's name when t was created.

Sourceval v : 'a key -> t

v k is the k with its type hidden.

Sourceval equal : t -> t -> bool

equal is the equality function of untyped keys.

Sourceval pp : t Fmt.t

pp fmt k prints the name of k.

Sourcemodule Set : sig ... end

Set implements sets over t elements.

Sourceval of_deps : Set.t -> unit value

of_deps keys is a value with keys as data-dependencies.

Sourceval deps : 'a value -> Set.t

deps v are v's data-dependencies.

Sourceval pp_deps : 'a value Fmt.t

pp_deps fmt v prints the name of the dependencies of v.

Parsing context

type context := Context.t

The type for values holding parsing context.

Sourceval add_to_context : 'a key -> 'a -> context -> context

Add a binding to a context.

context ks is a Cmdliner term that evaluates into a parsing context for command-line arguments.

Sourceval mem : context -> 'a value -> bool

mem c v is true iff all the dependencies of v have been evaluated.

Sourceval peek : context -> 'a value -> 'a option

peek c v is Some x if mem v and None otherwise.

Sourceval eval : context -> 'a value -> 'a

eval c v evaluates v in c's context, using default values if necessary.

Sourceval get : context -> 'a key -> 'a

get c k is k's value in c's context. If k is not present in c, it is k's default value.

Sourceval find : context -> 'a key -> 'a option

find c k is k's value in c's context or None if k is not present in c.

pps c fmt ks prints the keys ks using the context c to get their value.

OCaml

Innovation. Community. Security.