S.Option
val none : 'a option signal
none
is S.const None
.
some s
is S.map ~eq (fun v -> Some v) None
, where eq
uses s
's equality function to test the Some v
's equalities.
val value : ?eq:('a -> 'a -> bool) -> default:[ `Init of 'a signal | `Always of 'a signal ] ->
'a option signal -> 'a signal
value default s
is s
with only its Some v
values. Whenever s
is None
, if default
is `Always dv
then the current value of dv
is used instead. If default
is `Init dv
the current value of dv
is only used if there's no value at creation time, otherwise the last Some v
value of s
is used.
value ~default s
]t = v
if [s
]t = Some v
value ~default:(`Always d) s
]t =
[d
]t if [s
]t = None
value ~default:(`Init d) s
]0 =
[d
]0 if [s
]0 = None
value ~default:(`Init d) s
]t =
[value ~default:(`Init d) s
]t' if [s
]t = None
and t' is the greatest t' < t with [s
]t' <> None
or 0 if there is no such t'
.