Imandra_prelude.Option
The option type type 'a option = None | Some of 'a
is useful for representing partial functions and optional values.
type 'a t = 'a option
Map over the option.
map f None = None
map f (Some x) = Some (f x)
val map_or : default:'a -> ( 'b -> 'a ) -> 'b option -> 'a
val is_some : 'a option -> bool
Returns true
iff the argument is of the form Some x
val is_none : 'a option -> bool
Returns true
iff the argument is None
val return : 'a -> 'a option
Wrap a value into an option. return x = Some x
Monadic operator, useful for chaining multiple optional computations
Infix monadic operator, useful for chaining multiple optional computations together. It holds that (return x >>= f) = f x
Choice of a value
or_ ~else_:x None = x
or_ ~else_:x (Some y) = Some y
val exists : ( 'a -> bool ) -> 'a option -> bool
val for_all : ( 'a -> bool ) -> 'a option -> bool
val get_or : default:'a -> 'a option -> 'a
val fold : ( 'a -> 'b -> 'a ) -> 'a -> 'b option -> 'a