module Null: Js_null
'a null
type'a
t ='a Js.null
'a Js.null
val return : 'a -> 'a t
'a Js.null
containing a value of 'a
val test : 'a t -> bool
true
if the given value is empty
(null
), false
otherwiseval empty : 'a t
null
val bind : 'a t -> ([ `Arity_1 of 'a ], 'b) Js.Internal.fn -> 'b t
If 'a Js.null
contains a value, that value is unwrapped, mapped to a 'b
using
the given function a' -> 'b
, then wrapped back up and returned as 'b Js.null
let maybeGreetWorld (maybeGreeting: string Js.null) = Js.Null.bind maybeGreeting (fun greeting -> greeting ^ " world!")
val iter : 'a t -> ([ `Arity_1 of 'a ], unit) Js.Internal.fn -> unit
If 'a Js.null
contains a value, that value is unwrapped and applied to
the given function.
let maybeSay (maybeMessage: string Js.null) = Js.Null.iter maybeMessage (fun message -> Js.log message)
val from_opt : 'a option -> 'a t
'a option
to 'a Js.null
Some a | -> | return a |
None | -> | empty |
val to_opt : 'a t -> 'a option
'a Js.null
to 'a option
return a | -> | Some a |
empty | -> | None |