package cmdlang

  1. Overview
  2. Docs

Module Command.Nonempty_listSource

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

Sourcetype '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."