package cmdlang

  1. Overview
  2. Docs

A type to represent lists that are statically known to be non-empty.

type 'a t = 'a Cmdlang_ast.Ast.Nonempty_list.t =
  1. | :: : 'a * 'a list -> 'a t

The way this constructor is defined allows one to use the regular list literal syntax in a context where a non-empty list is expected. For example, the function Arg.flag expects a first argument of type string Nonempty_list.t and may be used that way:

Arg.flag [ "verbose" ] ~doc:"enable more output"

The point being that the following would be a type error:

Arg.flag [] ~doc:"enable more output"
OCaml

Innovation. Community. Security.