package core_kernel

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

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

type 'a t = 'a list
include Ppx_compare_lib.Comparable.S1 with type 'a t := 'a t
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
include Ppx_compare_lib.Equal.S1 with type 'a t := 'a t
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
include Sexplib0.Sexpable.S1 with type 'a t := 'a t
val t_of_sexp : (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a t
val sexp_of_t : ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t
val t_sexp_grammar : 'a Sexplib0.Sexp_grammar.t -> 'a t Sexplib0.Sexp_grammar.t
include Ppx_hash_lib.Hashable.S1 with type 'a t := 'a t
val hash_fold_t : (Base.Hash.state -> 'a -> Base.Hash.state) -> Base.Hash.state -> 'a t -> Base.Hash.state
include Ppx_quickcheck_runtime.Quickcheckable.S1 with type 'a t := 'a t
val quickcheck_generator : 'a Base_quickcheck.Generator.t -> 'a t Base_quickcheck.Generator.t
val quickcheck_observer : 'a Base_quickcheck.Observer.t -> 'a t Base_quickcheck.Observer.t
val quickcheck_shrinker : 'a Base_quickcheck.Shrinker.t -> 'a t Base_quickcheck.Shrinker.t

Constructors analogous to None and Some.

val none : _ t
val some : 'a nonempty_list -> 'a t
val is_none : _ t -> bool
val is_some : _ t -> bool
val value : 'a t -> default:'a nonempty_list -> 'a nonempty_list

value (some x) ~default = x and value none ~default = default.

val value_exn : 'a t -> 'a nonempty_list

value_exn (some x) = x. value_exn none raises. Unlike Option.value_exn, there is no ?message argument, so that calls to value_exn that do not raise also do not have to allocate.

val unchecked_value : 'a t -> 'a nonempty_list

unchecked_value (some x) = x. unchecked_value none returns an unspecified value. unchecked_value t is intended as an optimization of value_exn t when is_some t is known to be true.

val to_option : 'a t -> 'a nonempty_list option
val of_option : 'a nonempty_list option -> 'a t
module Optional_syntax : Core.Optional_syntax.S1 with type 'a t := 'a t and type 'a value := 'a nonempty_list
OCaml

Innovation. Community. Security.