Module Config.Env

A generative functor that produces a state-space that can read configuration values from the environment, provide stateful configuration setting and accessing operations, and a way to make a new t configuration record

Parameters

Signature

val get_debug : unit -> bool
val set_debug : bool -> unit
val get_headers : unit -> (string * string) list
val set_headers : (string * string) list -> unit
val make : (t -> 'a) -> 'a make

make f is a make function that will give f a safely constructed t.

Typically this is used to extend the constructor for t with new optional arguments.

E.g., we can construct a configuration that includes a t alongside a more specific field like so:

  type extended_config = {
    new_field: string;
    common: t;
  }

  let make : (new_field:string -> unit -> extended_config) make =
    Env.make (fun common ~new_field () -> { new_field; common })

  let _example : extended_config =
    make ~new_field:"foo" ~url_traces:"foo/bar" ~debug:true ()

As a special case, we can get the simple constructor function for t with Env.make (fun common () -> common)