Module S.Option

Option signals

val eq : ('a -> 'a -> bool) -> 'a option -> 'a option -> bool

eq f derives an equality function on options using f for testing Some _.

val hold_value : 'a -> 'a option signal -> 'a signal

hold_value i s is the last Some _ value of s or i if there was no such value:

  • [hold_some i s]t = i if [s]<t = None
  • [hold_some i s]t = v if [s]<=t = Some v

Uses s's equality on Some _.

Lifted module

val none : 'a option signal

none is const None.

val some : 'a signal -> 'a option signal

some s is map (fun v -> Some v) s and uses s's equality function to derive the obvious one on options.

val value : 'a option signal -> default:'a signal -> 'a signal

value s ~default is default when s is None:

  • [value s ~default]t = v if [s]t = Some v
  • [value s ~default]t = [default]t if [s]t = None

default's equality function is used for the resulting signal.

val get : ?eq:('a -> 'a -> bool) -> 'a option signal -> 'a signal

get s is map ~eq Option.get s.

val bind : ?eq:('b option -> 'b option -> bool) -> 'a option signal -> ('a -> 'b option) -> 'b option signal

bind ~eq s f is map ~eq (fun v -> Option.bind v f) s.

val join : ?eq:('a option -> 'a option -> bool) -> 'a option option signal -> 'a option signal

join ~eq oos is map ~eq Option.join oos.

val map : ?eq:('b option -> 'b option -> bool) -> ('a -> 'b) -> 'a option signal -> 'b option signal

map ~eq f s is map ~eq Option.map s.

val is_none : 'a option signal -> bool signal

is_none s is map Option.is_none s.

val is_some : 'a option signal -> bool signal

is_some s is map Option.is_some s.