Choice
Definitions
@Experimental
def assertAbsent(c: Choice[s, true, false]): Bool
SourceAsserts that c
is Absent
. Akin to a type ascription.
Always returns true
.
@Experimental
def assertPresent(c: Choice[s, false, true]): Bool
SourceAsserts that c
is Present
. Akin to a type ascription.
Always returns true
.
@Experimental
def filter(f: t -> Bool, c: Choice[t, a, p]): Choice[t, a or p, p]
SourceReturns Present(v)
if c
is Present(v)
and the predicate f(v)
is true. Otherwise returns None
.
The function f
must be pure.
@Experimental
def flatMap(f: s -> Choice[t, a2, p2], c: Choice[s, a1, p1]): Choice[t, a1 or (p1 and a2), p1 and p2]
SourceReturns f(v)
if c
is Present(v)
. Otherwise returns Absent
.
@Experimental
def flatten(c: Choice[Choice[t, a1, p1], a2, p2]): Choice[t, (a1 and p2) or a2, p1 and p2]
SourceReturns v
if c
is Present(v)
. Otherwise returns Absent
.
@Experimental
def getWithDefault(d: s, c: Choice[s, pres, abs]): s
SourceReturns v
if o
is Present(v).
Otherwise returns d
.
@Experimental
def invert(c: Choice[s, a, p], v: s): Choice[s, p, a]
SourceReturns Absent
if c
is Present(_)
. Otherwise returns Present(v)
.
@Experimental
def map(f: s -> t, c: Choice[s, a, p]): Choice[t, a, p]
SourceReturns Present(f(v))
if c
is Present(v)
. Otherwise returns Absent
.
@Experimental
def withDefault(default: { default = Choice[s, a2, p2] }, c: Choice[s, a1, p1]): Choice[s, a1 and a2, p1 or (a1 and p2)]
SourceReturns c
if it is Present(v)
. Otherwise returns default
.