package b0

  1. Overview
  2. Docs
Software construction and deployment kit

Install

dune-project
 Dependency

Authors

Maintainers

Sources

b0-0.0.6.tbz
sha512=e9aa779e66c08fc763019f16d4706f465d16c05d6400b58fbd0313317ef33ddea51952e2b058db28e65f7ddb7012f328c8bf02d8f1da17bb543348541a2587f0

doc/b0.file/B0_meta/Key/index.html

Module B0_meta.KeySource

Keys.

Typed keys

Sourceval make : ?doc:string -> ?default:'a -> string -> pp_value:'a B0_std.Fmt.t -> 'a key

make name ~default ~pp_value ~doc is a new metadata key with:

  • name the name used for UI interaction. It should be globally unique, the module automatically renames it if that happens not to be the case.
  • default is an optional default value for the key when undefined in a dictionary.
  • pp_value is used to format the key values for end-users.
  • doc is a documentation string for the key.
Sourceval make_tag : ?doc:string -> string -> bool key

make_tag ~doc name is a new tag key named name. Denote booleans that are false when absent (that's their default value). In effect this is strictly equivalent to:

make ?doc name ~default:false ~pp_value:Fmt.bool

Properties

Sourceval name : 'a key -> string

name k is k's name.

Sourceval default : 'a key -> 'a option

default k is a default value for the key (if any).

Sourceval get_default : 'a key -> 'a

get_default k is the default value of k. Raises Invalid_argument if k has no default.

Sourceval doc : 'a key -> string

doc k is k's documentation string.

Formatting

Sourceval pp_value : 'a key -> 'a B0_std.Fmt.t

pp k is k's value formatter.

Sourceval pp_name : 'a key B0_std.Fmt.t

pp_name k formats k's name with pp_name_str.

Existential keys

Sourcetype t =
  1. | V : 'a key -> t

The type for existential keys.

Predicates and comparison

Sourceval equal : t -> t -> bool

equal k0 k1 is true iff k and k' are the same key.

Sourceval compare : t -> t -> int

compare k0 k1 is a total order on keys compatible with equal.

Formatting

Sourceval pp_name_str : string B0_std.Fmt.t

pp_name_str formats a key name.

pp formats the key name with pp_name_str

Lookup keys by name

For UI purposes a map from key names to existential keys is maintained by the module.

Sourceval find : string -> t option

find n is the key named n (if any).

Sourceval get : string -> t

get n is the key named n. Raises Invalid_argument if there is no such key.

Sourceval get_or_suggest : string -> (t, t list) result

get_or_suggest n is the key named n or or a (possibly empty) list of suggested values whose name could match n.

Sourceval get_or_hint : string -> (t, string) result

get_or_hint n is the key named n or an error message that indicates that n could not be found with suggested names.

Sourceval list : unit -> t list
Sourceval fold : (t -> 'a -> 'a) -> 'a -> 'a
Sourceval get_list_or_hint : all_if_empty:bool -> string list -> (t list, string) result