package core_kernel

  1. Overview
  2. Docs
Industrial strength alternative to OCaml's standard library

Install

Dune Dependency

Authors

Maintainers

Sources

core_kernel-v0.15.0.tar.gz
sha256=34a0288f16027c6b90e4ad16cb5cc677d7063d310faf918748ce70f1745116c0

doc/core_kernel.uopt/Uopt/index.html

Module UoptSource

A Uopt.t is an unboxed option. This module is tricky and potentially unsafe. It should mostly not be used, and when it is, one must keep the Uopt.t inside their module, and not expose them (not even if they are given an abstract type).

'a Uopt.t is like 'a option, but doesn't box some values. It must not be used in a nested way, i.e. as 'a Uopt.t Uopt.t. It must also not be used for float Uopt.t array, since the representation of the array would vary depending on whether none or some is used to create the array, but float Uopt.t Uniform_array.t is fine. It should also not be used in a record that contains only monomorphic floats and float Uopt.ts, because the compiler would treat that as a float-only record and would unbox the record fields (as described in the documentation for writing C bindings).

Since 'a Uopt.t is abtract, manipulation of an 'a Uopt.t array does runtime checks to see if this is a float array. This can be mostly avoided with Uniform_array.t, although array creation will still do such checks, and you may want to use the set_with_caml_modify kind of function to skip the immediacy checks.

Sourcetype +'a t
Sourceval sexp_of_t : ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t
include Core.Invariant.S1 with type 'a t := 'a t
Sourceval invariant : 'a Base__Invariant_intf.inv -> 'a t Base__Invariant_intf.inv
Sourceval none : _ t
Sourceval some : 'a -> 'a t
Sourceval is_none : _ t -> bool
Sourceval is_some : _ t -> bool
Sourceval value_exn : 'a t -> 'a
Sourceval unsafe_value : 'a t -> 'a

It is safe to call unsafe_value t iff is_some t.

Sourceval to_option : 'a t -> 'a option
Sourceval of_option : 'a option -> 'a t
Sourcemodule Optional_syntax : Core.Optional_syntax.S1 with type 'a t := 'a t and type 'a value := 'a
OCaml

Innovation. Community. Security.