Choice

Definitions

@Experimental def assertAbsent(c: Choice[s, true, false]): BoolSource

Asserts that c is Absent. Akin to a type ascription.

Always returns true.

@Experimental def assertPresent(c: Choice[s, false, true]): BoolSource

Asserts 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]Source

Returns 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]Source

Returns 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]Source

Returns v if c is Present(v). Otherwise returns Absent.

@Experimental def getWithDefault(d: s, c: Choice[s, pres, abs]): sSource

Returns v if o is Present(v). Otherwise returns d.

@Experimental def invert(c: Choice[s, a, p], v: s): Choice[s, p, a]Source

Returns Absent if c is Present(_). Otherwise returns Present(v).

@Experimental def isAbsent(c: Choice[s, pres, abs]): BoolSource

Returns true if c is Absent.

@Experimental def isPresent(c: Choice[s, pres, abs]): BoolSource

Returns true if c is Present.

@Experimental def map(f: s -> t, c: Choice[s, a, p]): Choice[t, a, p]Source

Returns Present(f(v)) if c is Present(v). Otherwise returns Absent.

@Experimental def unbox(c: Choice[s, false, true]): sSource

Returns v where c must be Present(v).

@Experimental def withDefault(default: { default = Choice[s, a2, p2] }, c: Choice[s, a1, p1]): Choice[s, a1 and a2, p1 or (a1 and p2)]Source

Returns c if it is Present(v). Otherwise returns default.