Module Os.Name

OS names.

type id = string

The type for OS identifiers. Unless you create them yourself these strings are normalized: non-empty and lowercase ASCII.

type t =
  1. | Bsd of id
  2. | Darwin of id
  3. | Linux of id
  4. | Windows of id
  5. | Other of id

The type for OS names.

Names are sorted into families. The datum of each family has the concrete OS identifier.

Warning. Minor versions of the library may add new family enumerants or attach a family to an identifier previously classified as Other (moving between families should not happen, except to fix the odd bug). As such:

  • Pattern matching on Other "…" constants is not recommended. If you need to select such an identifier start by pattern matching on id before dropping to pattern matching on this type.
  • Unless you want your code to be informed by the introduction of a new family, end your pattern match with a catch all branch _ rather than Other _.
val id : t -> id

id n is the identifier of n.

val of_string : ?family:t -> string -> t

of_string s dermines an OS from s normalized by ASCII lowercasing. Unrecognized OS identifiers end up as Other with the normalized s. Strings printed by pp are guaranteed to parse (with the family as the identifier).

Identifiers returned by Os.name and classified into a proper family may be classified as Other _ by this function, as the contextual information provided by uname(2) is not available. However if family is provided, s is simply normalized and the family of family is used in the result.

Family constants

These constants can be used as family representatives.

val bsd : t

bsd is Bsd "bsd".

val darwin : t

darwin is Darwin "darwin".

val linux : t

linux is Linux "linux".

val windows : t

windows is Windows "windows".

val unknown : t

unknown is Other "unknown".

Predicates and comparisons

val equal : t -> t -> bool

equal asserts equality by family, except for Other id values which are each their own distinct family.

val compare : t -> t -> int

compare is a total order compatible with equal.

Formatting

val pp : t Fmt.t

pp formats families for inspection. The concrete identifier is not printed.

val pp_id : t Fmt.t

pp_id ppf n formats the id of n.