package core

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

This module extends Base.Option with bin_io, quickcheck, and support for ppx_optional.

type 'a t = 'a Base.Option.t
include Bin_prot.Binable.S1 with type 'a t := 'a t
val bin_shape_t : Bin_prot.Shape.t -> Bin_prot.Shape.t
val bin_size_t : ('a, 'a t) Bin_prot.Size.sizer1
val bin_write_t : ('a, 'a t) Bin_prot.Write.writer1
val bin_read_t : ('a, 'a t) Bin_prot.Read.reader1
val __bin_read_t__ : ('a, int -> 'a t) Bin_prot.Read.reader1
val bin_writer_t : ('a, 'a t) Bin_prot.Type_class.S1.writer
val bin_reader_t : ('a, 'a t) Bin_prot.Type_class.S1.reader
val bin_t : ('a, 'a t) Bin_prot.Type_class.S1.t
include Typerep_lib.Typerepable.S1 with type 'a t := 'a t
val typerep_of_t : 'a Typerep_lib.Std_internal.Typerep.t -> 'a t Typerep_lib.Std_internal.Typerep.t
val typename_of_t : 'a Typerep_lib.Typename.t -> 'a t Typerep_lib.Typename.t
val compare : 'a Base__Ppx_compare_lib.compare -> 'a option Base__Ppx_compare_lib.compare
val globalize : ('a -> 'a) -> 'a option -> 'a option
val hash_fold_t : 'a Base__Ppx_hash_lib.hash_fold -> 'a option Base__Ppx_hash_lib.hash_fold
val t_sexp_grammar : 'a Sexplib0.Sexp_grammar.t -> 'a option Sexplib0.Sexp_grammar.t
val equal : 'a Base__Equal.equal -> 'a option Base__Equal.equal
val invariant : 'a Base__Invariant_intf.inv -> 'a option Base__Invariant_intf.inv
val t_of_sexp : (Sexplib0__.Sexp.t -> 'a) -> Sexplib0__.Sexp.t -> 'a option
val sexp_of_t : ('a -> Sexplib0__.Sexp.t) -> 'a option -> Sexplib0__.Sexp.t
val both : 'a option -> 'b option -> ('a * 'b) option
val (<*>) : ('a -> 'b) option -> 'a option -> 'b option
val (<*) : 'a option -> unit option -> 'a option
val (*>) : unit option -> 'a option -> 'a option
val apply : ('a -> 'b) option -> 'a option -> 'b option
val map2 : 'a option -> 'b option -> f:('a -> 'b -> 'c) -> 'c option
val map3 : 'a option -> 'b option -> 'c option -> f:('a -> 'b -> 'c -> 'd) -> 'd option
module Applicative_infix : sig ... end
val (>>=) : 'a option -> ('a -> 'b option) -> 'b option
val (>>|) : 'a option -> ('a -> 'b) -> 'b option
module Monad_infix : sig ... end
val bind : 'a option -> f:('a -> 'b option) -> 'b option
val return : 'a -> 'a option
val map : 'a option -> f:('a -> 'b) -> 'b option
val join : 'a option option -> 'a option
val ignore_m : 'a option -> unit option
val all : 'a option list -> 'a list option
val all_unit : unit option list -> unit option
module Let_syntax : sig ... end
val value : 'a option -> default:'a -> 'a
val value_exn : ?here:Base__.Source_code_position0.t -> ?error:Base__.Error.t -> ?message:string -> 'a option -> 'a
val value_map : 'a option -> default:'b -> f:('a -> 'b) -> 'b
val value_or_thunk : 'a option -> default:(unit -> 'a) -> 'a
val fold : 'a option -> init:'acc -> f:('acc -> 'a -> 'acc) -> 'acc
val mem : 'a option -> 'a -> equal:('a -> 'a -> bool) -> bool
val length : 'a option -> int
val iter : 'a option -> f:('a -> unit) -> unit
val exists : 'a option -> f:('a -> bool) -> bool
val for_all : 'a option -> f:('a -> bool) -> bool
val find : 'a option -> f:('a -> bool) -> 'a option
val find_map : 'a option -> f:('a -> 'b option) -> 'b option
val to_list : 'a option -> 'a list
val to_array : 'a option -> 'a array
val call : 'a -> f:('a -> unit) option -> unit
val merge : 'a option -> 'a option -> f:('a -> 'a -> 'a) -> 'a option
val filter : 'a option -> f:('a -> bool) -> 'a option
val try_with : (unit -> 'a) -> 'a option
val try_with_join : (unit -> 'a option) -> 'a option
val some : 'a -> 'a option
val first_some : 'a option -> 'a option -> 'a option
val some_if : bool -> 'a -> 'a option
val is_none : 'a option -> bool
val is_some : 'a option -> bool
val is_empty : 'a option -> bool
  • deprecated [since 2019-07] Use [is_none] instead
val fold_result : 'a option -> init:'acc -> f:('acc -> 'a -> ('acc, 'e) Base__.Result.t) -> ('acc, 'e) Base__.Result.t
  • deprecated [since 2019-07] It is not a useful function
val fold_until : 'a option -> init:'acc -> f:('acc -> 'a -> ('acc, 'final) Base__.Container.Continue_or_stop.t) -> finish:('acc -> 'final) -> 'final
  • deprecated [since 2019-07] It is not a useful function
val min_elt : 'a option -> compare:('a -> 'a -> int) -> 'a option
  • deprecated [since 2019-07] Use [Fn.id] instead
val max_elt : 'a option -> compare:('a -> 'a -> int) -> 'a option
  • deprecated [since 2019-07] Use [Fn.id] instead
val count : 'a option -> f:('a -> bool) -> int
  • deprecated [since 2019-07] Use pattern matching instead
val sum : (module Base__.Container.Summable with type t = 'sum) -> 'a option -> f:('a -> 'sum) -> 'sum
  • deprecated [since 2019-07] Use [value_map ~default:Summable.zero ~f] instead
include Comparator.Derived with type 'a t := 'a t
type !'cmp comparator_witness
val comparator : ('a, 'cmp) Comparator.comparator -> ('a t, 'cmp comparator_witness) Comparator.comparator
include 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
val validate : none:unit Validate.check -> some:'a Validate.check -> 'a t Validate.check
module Stable : sig ... end
module Optional_syntax : Optional_syntax.S1 with type 'a t := 'a t and type 'a value := 'a

You might think that it's pointless to have Optional_syntax on options because OCaml already has nice syntax for matching on options. The reason to have this here is that you might have, for example, a tuple of an option and some other type that supports Optional_syntax. Since Optional_syntax can only be opted into at the granularity of the whole match expression, we need this Optional_syntax support for options in order to use it for the other half of the tuple.

OCaml

Innovation. Community. Security.