Module DA.Action¶
Action
Functions¶
- when
: Applicative f => Bool -> f () -> f ()
Conditional execution of
Action
expressions. For example,when final (archive contractId)
will archive the contract
contractId
if the Boolean valuefinal
isTrue
, and otherwise do nothing.This function has short-circuiting semantics, i.e., when both arguments are present and the first arguments evaluates to
False
, the second argument is not evaluated at all.
- unless
: Applicative f => Bool -> f () -> f ()
The reverse of
when
.This function has short-circuiting semantics, i.e., when both arguments are present and the first arguments evaluates to
False
, the second argument is not evaluated at all.
- foldrA
: Action m => (a -> b -> m b) -> b -> [a] -> m b
The
foldrA
is analogous tofoldr
, except that its result is encapsulated in an action. Note thatfoldrA
works from right-to-left over the list arguments.
- foldr1A
: Action m => (a -> a -> m a) -> [a] -> m a
foldr1A
is likefoldrA
but raises an error when presented with an empty list argument.
- foldlA
: Action m => (b -> a -> m b) -> b -> [a] -> m b
foldlA
is analogous tofoldl
, except that its result is encapsulated in an action. Note thatfoldlA
works from left-to-right over the list arguments.
- foldl1A
: Action m => (a -> a -> m a) -> [a] -> m a
The
foldl1A
is likefoldlA
but raises an errors when presented with an empty list argument.
- filterA
: Applicative m => (a -> m Bool) -> [a] -> m [a]
Filters the list using the applicative function: keeps only the elements where the predicate holds. Example: given a collection of Iou contract IDs one can find only the GBPs.
filterA (fmap (\iou -> iou.currency == "GBP") . fetch) iouCids
- replicateA
: Applicative m => Int -> m a -> m [a]
replicateA n act
performs the actionn
times, gathering the results.
- replicateA_
: Applicative m => Int -> m a -> m ()
Like
replicateA
, but discards the result.