jon.recoil.org

Module Core.Nonempty_listSource

A 'a t represents a non-empty list, as evidenced by the fact that there is no [] variant. The sexp representation is as a regular list (i.e., the same as the Stable.V3 module below).

For operations on a locally allocated 'a t, see Local_nonempty_list. For convenience, some functions here are also ppx_template'd over local, and we hope to fully merge the two after list is localized

include module type of struct include Base.Nonempty_list end
val compare__bits64 : ('a -> 'a -> int) -> 'a Base.Nonempty_list.t__bits64 -> 'a Base.Nonempty_list.t__bits64 -> int @@ portable
val compare__bits64__local : ('a @ local -> 'a @ local -> int) -> 'a Base.Nonempty_list.t__bits64 @ local -> 'a Base.Nonempty_list.t__bits64 @ local -> int @@ portable
val compare__bits32 : ('a -> 'a -> int) -> 'a Base.Nonempty_list.t__bits32 -> 'a Base.Nonempty_list.t__bits32 -> int @@ portable
val compare__bits32__local : ('a @ local -> 'a @ local -> int) -> 'a Base.Nonempty_list.t__bits32 @ local -> 'a Base.Nonempty_list.t__bits32 @ local -> int @@ portable
val compare__word : ('a -> 'a -> int) -> 'a Base.Nonempty_list.t__word -> 'a Base.Nonempty_list.t__word -> int @@ portable
val compare__word__local : ('a @ local -> 'a @ local -> int) -> 'a Base.Nonempty_list.t__word @ local -> 'a Base.Nonempty_list.t__word @ local -> int @@ portable
val compare__float64 : ('a -> 'a -> int) -> 'a Base.Nonempty_list.t__float64 -> 'a Base.Nonempty_list.t__float64 -> int @@ portable
val compare__float64__local : ('a @ local -> 'a @ local -> int) -> 'a Base.Nonempty_list.t__float64 @ local -> 'a Base.Nonempty_list.t__float64 @ local -> int @@ portable
val compare__float32 : ('a -> 'a -> int) -> 'a Base.Nonempty_list.t__float32 -> 'a Base.Nonempty_list.t__float32 -> int @@ portable
val compare__float32__local : ('a @ local -> 'a @ local -> int) -> 'a Base.Nonempty_list.t__float32 @ local -> 'a Base.Nonempty_list.t__float32 @ local -> int @@ portable
val equal__bits64 : ('a -> 'a -> bool) -> 'a Base.Nonempty_list.t__bits64 -> 'a Base.Nonempty_list.t__bits64 -> bool @@ portable
val equal__bits64__local : ('a @ local -> 'a @ local -> bool) -> 'a Base.Nonempty_list.t__bits64 @ local -> 'a Base.Nonempty_list.t__bits64 @ local -> bool @@ portable
val equal__bits32 : ('a -> 'a -> bool) -> 'a Base.Nonempty_list.t__bits32 -> 'a Base.Nonempty_list.t__bits32 -> bool @@ portable
val equal__bits32__local : ('a @ local -> 'a @ local -> bool) -> 'a Base.Nonempty_list.t__bits32 @ local -> 'a Base.Nonempty_list.t__bits32 @ local -> bool @@ portable
val equal__word : ('a -> 'a -> bool) -> 'a Base.Nonempty_list.t__word -> 'a Base.Nonempty_list.t__word -> bool @@ portable
val equal__word__local : ('a @ local -> 'a @ local -> bool) -> 'a Base.Nonempty_list.t__word @ local -> 'a Base.Nonempty_list.t__word @ local -> bool @@ portable
val equal__float64 : ('a -> 'a -> bool) -> 'a Base.Nonempty_list.t__float64 -> 'a Base.Nonempty_list.t__float64 -> bool @@ portable
val equal__float64__local : ('a @ local -> 'a @ local -> bool) -> 'a Base.Nonempty_list.t__float64 @ local -> 'a Base.Nonempty_list.t__float64 @ local -> bool @@ portable
val equal__float32 : ('a -> 'a -> bool) -> 'a Base.Nonempty_list.t__float32 -> 'a Base.Nonempty_list.t__float32 -> bool @@ portable
val equal__float32__local : ('a @ local -> 'a @ local -> bool) -> 'a Base.Nonempty_list.t__float32 @ local -> 'a Base.Nonempty_list.t__float32 @ local -> bool @@ portable
type ('a : value_or_null) t = 'a Base.Nonempty_list.t =
  1. | :: of 'a * 'a list
val compare : ('a : value_or_null). (('a : value_or_null) -> ('a : value_or_null) -> int) -> ('a : value_or_null) Core.Nonempty_list.t -> ('a : value_or_null) Core.Nonempty_list.t -> int
val compare__local : ('a : value_or_null). (('a : value_or_null) @ local -> ('a : value_or_null) @ local -> int) -> ('a : value_or_null) Core.Nonempty_list.t @ local -> ('a : value_or_null) Core.Nonempty_list.t @ local -> int
val equal : ('a : value_or_null). (('a : value_or_null) -> ('a : value_or_null) -> bool) -> ('a : value_or_null) Core.Nonempty_list.t -> ('a : value_or_null) Core.Nonempty_list.t -> bool
val equal__local : ('a : value_or_null). (('a : value_or_null) @ local -> ('a : value_or_null) @ local -> bool) -> ('a : value_or_null) Core.Nonempty_list.t @ local -> ('a : value_or_null) Core.Nonempty_list.t @ local -> bool
val hash_fold_t : ('a : value_or_null). (Ppx_hash_lib.Std.Hash.state -> ('a : value_or_null) -> Ppx_hash_lib.Std.Hash.state) -> Ppx_hash_lib.Std.Hash.state -> ('a : value_or_null) Core.Nonempty_list.t -> Ppx_hash_lib.Std.Hash.state
val globalize : ('a : value_or_null). ('a @ local -> 'a) -> 'a Core.Nonempty_list.t @ local -> 'a Core.Nonempty_list.t
include sig ... end
include sig ... end
include Sexplib0.Sexpable.S1 with type 'a t := 'a Core.Nonempty_list.t
val t_of_sexp : 'a. (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a Core.Nonempty_list.t
val sexp_of_t : 'a. ('a -> Sexplib0.Sexp.t) -> 'a Core.Nonempty_list.t -> Sexplib0.Sexp.t
val t_sexp_grammar : 'a. 'a Sexplib0.Sexp_grammar.t -> 'a Core.Nonempty_list.t Sexplib0.Sexp_grammar.t @@ portable
include Base.Container.S1 with type 'a t := 'a Core.Nonempty_list.t
include sig ... end
include sig ... end
include sig ... end
include sig ... end
include sig ... end
include sig ... end
include Base.Invariant.S1 with type 'a t := 'a Core.Nonempty_list.t
val invariant : ('a -> unit) -> 'a Core.Nonempty_list.t -> unit
include Base.Monad.S__'value_or_null_mod_maybe_null'__local with type ('a : value_or_null) t := 'a Core.Nonempty_list.t
val return : 'a -> 'a Core.Nonempty_list.t

Convert a value to a t.

val bind : 'a Core.Nonempty_list.t -> f:('a -> 'b Core.Nonempty_list.t) @ local -> 'b Core.Nonempty_list.t

Sequences computations. bind t ~f computes f v for value(s) v in t. Well-behaved monads satisfy these "laws" (where ( >>= ) is the infix bind operator):

  • map t ~f is equivalent to bind t ~f:(fun x -> return (f x))
  • return x >>= f is equivalent to f x
  • t >>= return is equivalent to t
  • (t >>= f) >>= g is equivalent to t >>= fun x -> f x >>= g

Combines nested t into just one layer. Equivalent to bind t ~f:Fn.id.

val ignore_m : 'a Core.Nonempty_list.t -> unit Core.Nonempty_list.t

Ignores contained values of t. Equivalent to map t ~f:ignore.

val all : 'a Core.Nonempty_list.t list -> 'a list Core.Nonempty_list.t

Combines a list of t.

val all_unit : unit Core.Nonempty_list.t list -> unit Core.Nonempty_list.t

Combines a list of t whose contents are unimportant.

val (>>=) : 'a Core.Nonempty_list.t -> ('a -> 'b Core.Nonempty_list.t) @ local -> 'b Core.Nonempty_list.t

Infix bind.

val (>>|) : 'a Core.Nonempty_list.t -> ('a -> 'b) @ local -> 'b Core.Nonempty_list.t

Infix map.

include Base.Indexed_container.S1 with type 'a t := 'a Core.Nonempty_list.t
include Base.Container.S1__''value'' with type 'a t := 'a Core.Nonempty_list.t
include sig ... end
include sig ... end
val is_empty : 'a 'p1 'p2. 'a Core.Nonempty_list.t -> bool
val exists : 'a 'p1 'p2. 'a Core.Nonempty_list.t -> f:('a -> bool) @ local -> bool

Returns true if and only if there exists an element for which the provided function evaluates to true. This is a short-circuiting operation.

val for_all : 'a 'p1 'p2. 'a Core.Nonempty_list.t -> f:('a -> bool) @ local -> bool

Returns true if and only if the provided function evaluates to true for all elements. This is a short-circuiting operation.

val count : 'a 'p1 'p2. 'a Core.Nonempty_list.t -> f:('a -> bool) @ local -> int

Returns the number of elements for which the provided function evaluates to true.

val find : 'a 'p1 'p2. 'a Core.Nonempty_list.t -> f:('a -> bool) @ local -> 'a option

Returns as an option the first element for which f evaluates to true.

val min_elt : 'a 'p1 'p2. 'a Core.Nonempty_list.t -> compare:('a -> 'a -> int) @ local -> 'a option

Returns a min (resp. max) element from the collection using the provided compare function. In case of a tie, the first element encountered while traversing the collection is returned. The implementation uses fold so it has the same complexity as fold. Returns None iff the collection is empty.

val max_elt : 'a 'p1 'p2. 'a Core.Nonempty_list.t -> compare:('a -> 'a -> int) @ local -> 'a option
include sig ... end
val sum : 'a 'sum 'p1 'p2. (module Base__.Container_intf.Definitions.Summable__value_or_null with type t = 'sum) -> 'a Core.Nonempty_list.t -> f:('a -> 'sum) @ local -> 'sum

Returns the sum of f i for all i in the container. The order in which the elements will be summed is unspecified.

val iter_until : 'a 'p1 'p2 'final. 'a Core.Nonempty_list.t -> f:('a -> (unit, 'final) Base.Container.Continue_or_stop.t) @ local -> finish:(unit -> 'final) @ local -> 'final

iter_until t ~f ~finish is a short-circuiting version of iter. If f returns Stop x the computation ceases and returns x. If f always returns Continue () the final result is computed by finish.

val fold : 'a 'p1 'p2 'acc. 'a Core.Nonempty_list.t -> init:'acc -> f:('acc -> 'a -> 'acc) @ local -> 'acc

fold t ~init ~f returns f (... f (f (f init e1) e2) e3 ...) en, where e1..en are the elements of t.

val fold_result : 'a 'p1 'p2 'acc 'e. 'a Core.Nonempty_list.t -> init:'acc -> f:('acc -> 'a -> ('acc, 'e) Stdlib.result) @ local -> ('acc, 'e) Stdlib.result

fold_result t ~init ~f is a short-circuiting version of fold that runs in the Result monad. If f returns an Error _, that value is returned without any additional invocations of f.

val find_map : 'a 'p1 'p2 'b. 'a Core.Nonempty_list.t -> f:('a -> 'b option) @ local -> 'b option

Returns the first evaluation of f that returns Some, and returns None if there is no such element.

include sig ... end
val fold_until : 'a 'p1 'p2 'acc 'final. 'a Core.Nonempty_list.t -> init:'acc -> f:('acc -> 'a -> ('acc, 'final) Base.Container.Continue_or_stop.t) @ local -> finish:('acc -> 'final) @ local -> 'final

fold_until t ~init ~f ~finish is a short-circuiting version of fold. If f returns Stop _ the computation ceases and results in that value. If f returns Continue _, the fold will proceed. If f never returns Stop _, the final result is computed by finish.

Example:

  type maybe_negative =
    | Found_negative of int
    | All_nonnegative of { sum : int }

  (** [first_neg_or_sum list] returns the first negative number in [list], if any,
      otherwise returns the sum of the list. *)
  let first_neg_or_sum =
    List.fold_until ~init:0
      ~f:(fun sum x ->
        if x < 0
        then Stop (Found_negative x)
        else Continue (sum + x))
      ~finish:(fun sum -> All_nonnegative { sum })
  ;;

  let x = first_neg_or_sum [1; 2; 3; 4; 5]
  val x : maybe_negative = All_nonnegative {sum = 15}

  let y = first_neg_or_sum [1; 2; -3; 4; 5]
  val y : maybe_negative = Found_negative -3
include sig ... end
val mem : 'a 'p1 'p2. 'a Core.Nonempty_list.t -> 'a -> equal:('a -> 'a -> bool) @ local -> bool

Checks whether the provided element is there, using equal.

include sig ... end
val to_array : 'a. 'a Core.Nonempty_list.t -> 'a array
include Base.Container.Generic_types__''value'' with type ('a, _, _) t := 'a Core.Nonempty_list.t with type 'a elt := 'a

These are all like their equivalents in Container except that an index starting at 0 is added as the first argument to f.

include sig ... end
include sig ... end
val existsi : 'a 'p1 'p2. 'a Core.Nonempty_list.t -> f:(int -> 'a -> bool) @ local -> bool
val for_alli : 'a 'p1 'p2. 'a Core.Nonempty_list.t -> f:(int -> 'a -> bool) @ local -> bool
val counti : 'a 'p1 'p2. 'a Core.Nonempty_list.t -> f:(int -> 'a -> bool) @ local -> int
include sig ... end
include sig ... end
val foldi : 'a 'p1 'p2 'acc. 'a Core.Nonempty_list.t -> init:'acc -> f:(int -> 'acc -> 'a -> 'acc) @ local -> 'acc
val iteri_until : 'a 'p1 'p2 'final. 'a Core.Nonempty_list.t -> f:(int -> 'a -> (unit, 'final) Base.Container.Continue_or_stop.t) @ local -> finish:(int -> 'final) @ local -> 'final
val find_mapi : 'a 'p1 'p2 'b. 'a Core.Nonempty_list.t -> f:(int -> 'a -> 'b option) @ local -> 'b option
include sig ... end
val foldi_until : 'a 'p1 'p2 'acc 'final. 'a Core.Nonempty_list.t -> init:'acc -> f: (int -> 'acc -> 'a -> ('acc, 'final) Base.Container.Continue_or_stop.t) @ local -> finish:(int -> 'acc -> 'final) @ local -> 'final
include sig ... end
val findi : 'a 'p1 'p2. 'a Core.Nonempty_list.t -> f:(int -> 'a -> bool) @ local -> (int * 'a) option
include sig ... end
include sig ... end
val create : ('a : value_or_null). 'a -> 'a Base.List.t -> 'a Core.Nonempty_list.t
val init : ('a : value_or_null). int -> f:(int -> 'a) @ local -> 'a Core.Nonempty_list.t

init n ~f creates a list of length n where the element at index i is the value of f i. Raises if n < 1. f is called on indices from the highest to lowest, so the order of side effects is reversed: Nonempty_list.init 3 ~f:print_int prints

210.

val of_list : ('a : value_or_null). 'a Base.List.t -> 'a Core.Nonempty_list.t option
val of_list_or_null : ('a : value_or_null). 'a Base.List.t -> 'a Core.Nonempty_list.t Basement.Or_null_shim.t
val of_list_error : ('a : value_or_null). 'a Base.List.t -> 'a Core.Nonempty_list.t Base.Or_error.t
val of_list_exn : ('a : value_or_null). 'a Base.List.t -> 'a Core.Nonempty_list.t
val to_list : ('a : value_or_null). 'a Core.Nonempty_list.t -> 'a Base.List.t
val singleton : ('a : value_or_null). 'a -> 'a Core.Nonempty_list.t
val cons : ('a : value_or_null). 'a -> 'a Core.Nonempty_list.t -> 'a Core.Nonempty_list.t
val hd : ('a : value_or_null). 'a Core.Nonempty_list.t -> 'a
val tl : ('a : value_or_null). 'a Core.Nonempty_list.t -> 'a Base.List.t
val nth : ('a : value_or_null). 'a Core.Nonempty_list.t -> int -> 'a Base.Option.t
val nth_exn : ('a : value_or_null). 'a Core.Nonempty_list.t -> int -> 'a
val reverse : ('a : value_or_null). 'a Core.Nonempty_list.t -> 'a Core.Nonempty_list.t
val append : ('a : value_or_null). 'a Core.Nonempty_list.t -> 'a Base.List.t -> 'a Core.Nonempty_list.t
val (@) : ('a : value_or_null). 'a Core.Nonempty_list.t -> 'a Core.Nonempty_list.t -> 'a Core.Nonempty_list.t
val filter : ('a : value_or_null). 'a Core.Nonempty_list.t -> f:('a -> bool) @ local -> 'a Base.List.t
val filteri : ('a : value_or_null). 'a Core.Nonempty_list.t -> f:(int -> 'a -> bool) @ local -> 'a Base.List.t
val last : ('a : value_or_null). 'a Core.Nonempty_list.t -> 'a
val iter : 'a Core.Nonempty_list.t -> f:('a -> unit) @ local -> unit
val iteri : 'a Core.Nonempty_list.t -> f:(int -> 'a -> unit) @ local -> unit
val length : ('a : value_or_null). 'a Core.Nonempty_list.t -> int
include sig ... end
val map : ('a : value_or_null) ('b : value_or_null). 'a Core.Nonempty_list.t -> f:('a -> 'b) @ local -> 'b Core.Nonempty_list.t
val mapi : ('a : value_or_null) ('b : value_or_null). 'a Core.Nonempty_list.t -> f:(int -> 'a -> 'b) @ local -> 'b Core.Nonempty_list.t
val filter_map : ('a : value_or_null) ('b : value_or_null). 'a Core.Nonempty_list.t -> f:('a -> 'b Base.Option.t) @ local -> 'b Base.List.t
val filter_mapi : ('a : value_or_null) ('b : value_or_null). 'a Core.Nonempty_list.t -> f:(int -> 'a -> 'b Base.Option.t) @ local -> 'b Base.List.t
val concat_map : ('a : value_or_null) ('b : value_or_null). 'a Core.Nonempty_list.t -> f:('a -> 'b Core.Nonempty_list.t) @ local -> 'b Core.Nonempty_list.t
val reduce : 'a Core.Nonempty_list.t -> f:('a -> 'a -> 'a) @ local -> 'a @@ portable
val append' : 'a list -> 'a Core.Nonempty_list.t -> 'a Core.Nonempty_list.t @@ portable
val unzip : ('a * 'b) Core.Nonempty_list.t -> 'a Core.Nonempty_list.t * 'b Core.Nonempty_list.t @@ portable
val unzip3 : ('a * 'b * 'c) Core.Nonempty_list.t -> 'a Core.Nonempty_list.t * 'b Core.Nonempty_list.t * 'c Core.Nonempty_list.t @@ portable
val zip_exn : 'a Core.Nonempty_list.t -> 'b Core.Nonempty_list.t -> ('a * 'b) Core.Nonempty_list.t @@ portable
val zip3_exn : 'a Core.Nonempty_list.t -> 'b Core.Nonempty_list.t -> 'c Core.Nonempty_list.t -> ('a * 'b * 'c) Core.Nonempty_list.t @@ portable
val map2 : 'a Core.Nonempty_list.t -> 'b Core.Nonempty_list.t -> f:('a -> 'b -> 'c) @ local -> 'c Core.Nonempty_list.t Base.List.Or_unequal_lengths.t @@ portable
val map2_exn : 'a Core.Nonempty_list.t -> 'b Core.Nonempty_list.t -> f:('a -> 'b -> 'c) @ local -> 'c Core.Nonempty_list.t @@ portable
val filter_opt : 'a option Core.Nonempty_list.t -> 'a list @@ portable
val drop_last : 'a Core.Nonempty_list.t -> 'a list @@ portable
val to_sequence : 'a Core.Nonempty_list.t -> 'a Base.Sequence.t @@ portable
val sort : 'a Core.Nonempty_list.t -> compare:('a -> 'a -> int) @ local -> 'a Core.Nonempty_list.t @@ portable
val group : 'a Core.Nonempty_list.t -> break:('a -> 'a -> bool) @ local -> 'a Core.Nonempty_list.t Core.Nonempty_list.t @@ portable
val sort_and_group : 'a Core.Nonempty_list.t -> compare:('a -> 'a -> int) @ local -> 'a Core.Nonempty_list.t Core.Nonempty_list.t @@ portable
val stable_sort : 'a Core.Nonempty_list.t -> compare:('a -> 'a -> int) @ local -> 'a Core.Nonempty_list.t @@ portable
val stable_dedup : 'a Core.Nonempty_list.t -> compare:('a -> 'a -> int) -> 'a Core.Nonempty_list.t @@ portable
val dedup_and_sort : 'a Core.Nonempty_list.t -> compare:('a -> 'a -> int) @ local -> 'a Core.Nonempty_list.t @@ portable
val permute : ?random_state:Base.Random.State.t -> 'a Core.Nonempty_list.t -> 'a Core.Nonempty_list.t @@ portable
val random_element : ?random_state:Base.Random.State.t -> 'a Core.Nonempty_list.t -> 'a @@ portable
val cartesian_product : 'a Core.Nonempty_list.t -> 'b Core.Nonempty_list.t -> ('a * 'b) Core.Nonempty_list.t @@ portable
val fold_nonempty : 'a Core.Nonempty_list.t -> init:('a -> 'acc) @ local -> f:('acc -> 'a -> 'acc) @ local -> 'acc @@ portable
val fold_right : 'a Core.Nonempty_list.t -> init:'b -> f:('a -> 'b -> 'b) @ local -> 'b @@ portable
val folding_map : 'a Core.Nonempty_list.t -> init:'b -> f:('b -> 'a -> 'b * 'c) @ local -> 'c Core.Nonempty_list.t @@ portable
val fold_map : 'a Core.Nonempty_list.t -> init:'acc -> f:('acc -> 'a -> 'acc * 'b) @ local -> 'acc * 'b Core.Nonempty_list.t @@ portable
val findi_exn : 'a Core.Nonempty_list.t -> f:(int -> 'a -> bool) @ local -> int * 'a @@ portable
val all_equal : 'a Core.Nonempty_list.t -> equal:('a -> 'a -> bool) @ local -> 'a option @@ portable

all_equal returns a single element of the list that is equal to all other elements, or None if no such element exists.

val is_sorted : 'a Core.Nonempty_list.t -> compare:('a -> 'a -> int) @ local -> bool @@ portable

is_sorted t ~compare returns true iff for all adjacent a1; a2 in t, compare a1 a2 <= 0.

val is_sorted_strictly : 'a Core.Nonempty_list.t -> compare:('a -> 'a -> int) @ local -> bool @@ portable

is_sorted_strictly t ~compare returns true iff for all adjacent a1; a2 in t, compare a1 a2 < 0.

val min_elt' : 'a Core.Nonempty_list.t -> compare:('a -> 'a -> int) @ local -> 'a @@ portable

min_elt' and max_elt' differ from min_elt and max_elt (included in Container.S1) in that they don't return options.

val max_elt' : 'a Core.Nonempty_list.t -> compare:('a -> 'a -> int) @ local -> 'a @@ portable

transpose takes an n x m list of lists to an m x n list of lists. Hence, if the input lists are all non-empty, the output lists will also all be non-empty.

val map_add_multi : ('k, 'v Core.Nonempty_list.t, 'cmp) Base.Map.t -> key:'k -> data:'v -> ('k, 'v Core.Nonempty_list.t, 'cmp) Base.Map.t @@ portable

Like Map.add_multi, but comes with a guarantee that the range of the returned map is all nonempty lists.

val hashtbl_add_multi : ('k, 'v Core.Nonempty_list.t) Base.Hashtbl.t -> key:'k -> data:'v -> unit @@ portable

Like Hashtbl.add_multi, but comes with a guarantee that list that's added to or created is a nonempty list.

val map_of_alist_multi : ('k * 'v) list -> comparator:('k, 'cmp) Base.Comparator.Module.t -> ('k, 'v Core.Nonempty_list.t, 'cmp) Base.Map.t @@ portable

Like Map.of_alist_multi, but comes with a guarantee that the range of the returned map is all nonempty lists.

val map_of_alist_multi_rev : ('k * 'v) list -> comparator:('k, 'cmp) Base.Comparator.Module.t -> ('k, 'v Core.Nonempty_list.t, 'cmp) Base.Map.t @@ portable

Like map_of_alist_multi but the elements in the resulting nonempty lists will be in the reverse order of the input list. Uses of this function should probably be replaced with map_of_alist_multi

val map_of_sequence_multi : ('k * 'v) Base.Sequence.t -> comparator:('k, 'cmp) Base.Comparator.Module.t -> ('k, 'v Core.Nonempty_list.t, 'cmp) Base.Map.t @@ portable

Like Map.of_sequence_multi, but comes with a guarantee that the range of the returned map is all nonempty lists.

val map_of_sequence_multi_rev : ('k * 'v) Base.Sequence.t -> comparator:('k, 'cmp) Base.Comparator.Module.t -> ('k, 'v Core.Nonempty_list.t, 'cmp) Base.Map.t @@ portable

Like map_of_sequence_multi but the elements in the resulting nonempty lists will be in the reverse order of the input sequence. Uses of this function should probably be replaced with map_of_sequence_multi

val map_of_list_with_key_multi : 'v list -> comparator:('k, 'cmp) Base.Comparator.Module.t -> get_key:('v -> 'k) -> ('k, 'v Core.Nonempty_list.t, 'cmp) Base.Map.t @@ portable

Like Map.of_list_with_key_multi, but comes with a guarantee that the range of the returned map is all nonempty lists.

val map_of_list_with_key_multi_rev : 'v list -> comparator:('k, 'cmp) Base.Comparator.Module.t -> get_key:('v -> 'k) -> ('k, 'v Core.Nonempty_list.t, 'cmp) Base.Map.t @@ portable

Like map_of_list_with_key_multi but the elements in the resulting nonempty lists will be in the reverse order of the input list. Uses of this function should probably be replaced with map_of_list_with_key_multi

val combine_errors : ('ok, 'err) Base.Result.t Core.Nonempty_list.t -> ('ok Core.Nonempty_list.t, 'err Core.Nonempty_list.t) Base.Result.t @@ portable

Like Result.combine_errors but for non-empty lists

val combine_errors_unit : (unit, 'err) Base.Result.t Core.Nonempty_list.t -> (unit, 'err Core.Nonempty_list.t) Base.Result.t @@ portable

Like Result.combine_errors_unit but for non-empty lists

val combine_or_errors : 'a Base.Or_error.t Core.Nonempty_list.t -> 'a Core.Nonempty_list.t Base.Or_error.t @@ portable

Like Or_error.combine_errors but for non-empty lists

val combine_or_errors_unit : unit Base.Or_error.t Core.Nonempty_list.t -> unit Base.Or_error.t @@ portable

Like Or_error.combine_errors_unit but for non-empty lists

val filter_ok_at_least_one : 'a Base.Or_error.t Core.Nonempty_list.t -> 'a Core.Nonempty_list.t Base.Or_error.t @@ portable

Like Or_error.filter_ok_at_least_one but for non-empty lists.

In particular it:

  1. Returns a 'a t Or_error.t, statically ensuring that in the Ok l case, l is nonempty.
  1. Takes a 'a Or_error.t t, ensuring that in the Error e case, e is informative, rather than having been constructed from an empty list.
val option_all : 'a option Core.Nonempty_list.t -> 'a Core.Nonempty_list.t option @@ portable

Like Option.all but for non-empty lists

val remove_consecutive_duplicates : ?which_to_keep:[ `First | `Last ] -> 'a Core.Nonempty_list.t -> equal:('a -> 'a -> bool) @ local -> 'a Core.Nonempty_list.t @@ portable

Returns the given t with consecutive duplicates removed. The relative order of the other elements is unaffected. The element kept from a run of duplicates is determined by which_to_keep.

val partition_tf : 'a Core.Nonempty_list.t -> f:('a -> bool) @ local -> ('a, 'a) Partition.t @@ portable

partition_tf t ~f returns a pair t1, t2, where t1 is all elements of t that satisfy f, and t2 is all elements of t that do not satisfy f. The "tf" suffix is mnemonic to remind readers that the result is (trues, falses).

At least one of the two parts must be nonempty, which is represented by the type of Partition.t.

val partition_tf' : 'a Core.Nonempty_list.t -> f:('a -> bool) @ local -> 'a list * 'a list @@ portable

Like partition_tf, but returns the parts in two lists instead.

val partition_map : 'a Core.Nonempty_list.t -> f:('a -> ('fst, 'snd) Base.Either.t) @ local -> ('fst, 'snd) Partition.t @@ portable

partition_map t ~f partitions t according to f.

At least one of the two parts must be nonempty, which is represented by the type of Partition.t.

val partition_map' : 'a Core.Nonempty_list.t -> f:('a -> ('fst, 'snd) Base.Either.t) @ local -> 'fst list * 'snd list @@ portable

Like partition_map, but returns the parts in two lists instead.

val partition_result : ('ok, 'error) Base.Result.t Core.Nonempty_list.t -> ('ok, 'error) Partition.t @@ portable

partition_result t returns a pair t1, t2, where t1 is the all Ok elements in t and t2 is the list of all Error elements. The order of elements in the input list is preserved.

At least one of the two parts must be nonempty, which is represented by the type of Partition.t.

val partition_result' : ('ok, 'error) Base.Result.t Core.Nonempty_list.t -> 'ok list * 'error list @@ portable

Like partition_result, but returns the parts in two lists instead.

val partition3_map : 'a Core.Nonempty_list.t -> f:('a -> [ `Fst of 'fst | `Snd of 'snd | `Trd of 'trd ]) @ local -> ('fst, 'snd, 'trd) Partition3.t @@ portable
include sig ... end
Sourceval quickcheck_generator__portable : 'a. 'a Ppx_quickcheck_runtime.Base_quickcheck.Generator.t @ portable -> 'a Core.Nonempty_list.t Ppx_quickcheck_runtime.Base_quickcheck.Generator.t @ portable @@ portable
Sourceval quickcheck_observer__portable : 'a. 'a Ppx_quickcheck_runtime.Base_quickcheck.Observer.t @ portable -> 'a Core.Nonempty_list.t Ppx_quickcheck_runtime.Base_quickcheck.Observer.t @ portable @@ portable
Sourceval quickcheck_shrinker__portable : 'a. 'a Ppx_quickcheck_runtime.Base_quickcheck.Shrinker.t @ portable -> 'a Core.Nonempty_list.t Ppx_quickcheck_runtime.Base_quickcheck.Shrinker.t @ portable @@ portable
type 'a nonempty_list := 'a Core.Nonempty_list.t
Sourceval validate_indexed : 'a Validate.check -> 'a Core.Nonempty_list.t Validate.check @@ portable

validates a list, naming each element by its position in the list (where the first position is 1, not 0).

Sourceval validate : name:('a -> string) -> 'a Validate.check -> 'a Core.Nonempty_list.t Validate.check @@ portable

validates a list, naming each element using a user-defined function for computing the name.

Returns a flag that must be passed one or more times. See Command.Param.one_or_more_as_pair.

Sourceval comma_separated_argtype : ?key:'a Core.Nonempty_list.t Univ_map.Multi.Key.t -> ?strip_whitespace:bool -> ?unique_values:bool -> 'a Command.Param.Arg_type.t -> 'a Core.Nonempty_list.t Command.Param.Arg_type.t

Accepts comma-separated lists of arguments parsed by t. See Command.Param.Arg_type.comma_separated.

Requires one or more of an anonymous argument.

Sourcemodule Option : sig ... end

This module provides 0-alloc versions of to_list and of_list, via some and allowing you to match%optional on a list, respectively.

Sourcemodule Unstable : sig ... end
Sourcemodule Stable : sig ... end