Choice

0.40.0

Definitions

@Experimental

def assertAbsent [s] ( c : Choice[s, true, false] ) : Bool \ Pure

Source

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

Always returns true.

@Experimental

def assertPresent [s] ( c : Choice[s, false, true] ) : Bool \ Pure

Source

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

Always returns true.

@Experimental

def filter [tap] ( f : t -> Bool c : Choice[t, a, p] ) : Choice[t, a or p, p] \ Pure

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 [sta1p1a2p2] ( f : s -> Choice[t, a2, p2] c : Choice[s, a1, p1] ) : Choice[t, a1 or (p1 and a2), p1 and p2] \ Pure

Source

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

@Experimental

def flatten [ta1p1a2p2] ( c : Choice[Choice[t, a1, p1], a2, p2] ) : Choice[t, (a1 and p2) or a2, p1 and p2] \ Pure

Source

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

@Experimental

def getWithDefault [spresabs] ( d : s c : Choice[s, pres, abs] ) : s \ Pure

Source

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

@Experimental

def invert [sap] ( c : Choice[s, a, p] v : s ) : Choice[s, p, a] \ Pure

Source

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

@Experimental

def isAbsent [spresabs] ( c : Choice[s, pres, abs] ) : Bool \ Pure

Source

Returns true if c is Absent.

@Experimental

def isPresent [spresabs] ( c : Choice[s, pres, abs] ) : Bool \ Pure

Source

Returns true if c is Present.

@Experimental

def map [stap] ( f : s -> t c : Choice[s, a, p] ) : Choice[t, a, p] \ Pure

Source

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

@Experimental

def unbox [s] ( c : Choice[s, false, true] ) : s \ Pure

Source

Returns v where c must be Present(v).

@Experimental

def withDefault [sa1p1a2p2] ( default : { default = Choice[s, a2, p2] } c : Choice[s, a1, p1] ) : Choice[s, a1 and a2, p1 or (a1 and p2)] \ Pure

Source

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