Choice
0.40.0
Definitions
@Experimental
Source
def
assertAbsent
[s]
(
c :
Choice[s, true, false]
)
: Bool
\ Pure
Asserts that c
is Absent
. Akin to a type ascription.
Always returns true
.
@Experimental
Source
def
assertPresent
[s]
(
c :
Choice[s, false, true]
)
: Bool
\ Pure
Asserts that c
is Present
. Akin to a type ascription.
Always returns true
.
@Experimental
Source
def
filter
[tap]
(
f :
t -> Bool
c :
Choice[t, a, p]
)
: Choice[t, a or p, p]
\ Pure
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
Source
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
Returns f(v)
if c
is Present(v)
. Otherwise returns Absent
.
@Experimental
Source
def
flatten
[ta1p1a2p2]
(
c :
Choice[Choice[t, a1, p1], a2, p2]
)
: Choice[t, (a1 and p2) or a2, p1 and p2]
\ Pure
Returns v
if c
is Present(v)
. Otherwise returns Absent
.
@Experimental
Source
def
getWithDefault
[spresabs]
(
d :
s
c :
Choice[s, pres, abs]
)
: s
\ Pure
Returns v
if o
is Present(v).
Otherwise returns d
.
@Experimental
Source
def
invert
[sap]
(
c :
Choice[s, a, p]
v :
s
)
: Choice[s, p, a]
\ Pure
Returns Absent
if c
is Present(_)
. Otherwise returns Present(v)
.
@Experimental
Source
def
isAbsent
[spresabs]
(
c :
Choice[s, pres, abs]
)
: Bool
\ Pure
Returns true
if c
is Absent
.
@Experimental
Source
def
isPresent
[spresabs]
(
c :
Choice[s, pres, abs]
)
: Bool
\ Pure
Returns true
if c
is Present
.
@Experimental
Source
def
map
[stap]
(
f :
s -> t
c :
Choice[s, a, p]
)
: Choice[t, a, p]
\ Pure
Returns Present(f(v))
if c
is Present(v)
. Otherwise returns Absent
.
@Experimental
Source
def
unbox
[s]
(
c :
Choice[s, false, true]
)
: s
\ Pure
Returns v
where c
must be Present(v)
.
@Experimental
Source
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
Returns c
if it is Present(v)
. Otherwise returns default
.