Module DA.Action¶
Action
Functions¶
- when
: Applicative f => Bool -> f () -> f ()
Conditional execution of
Actionexpressions. For example,when final (archive contractId)
will archive the contract
contractIdif the Boolean valuefinalisTrue, 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
True, the second argument is not evaluated at all.
- foldrA
: Action m => (a -> b -> m b) -> b -> [a] -> m b
The
foldrAis analogous tofoldr, except that its result is encapsulated in an action. Note thatfoldrAworks from right-to-left over the list arguments.
- foldr1A
: Action m => (a -> a -> m a) -> [a] -> m a
foldr1Ais likefoldrAbut raises an error when presented with an empty list argument.
- foldlA
: Action m => (b -> a -> m b) -> b -> [a] -> m b
foldlAis analogous tofoldl, except that its result is encapsulated in an action. Note thatfoldlAworks from left-to-right over the list arguments.
- foldl1A
: Action m => (a -> a -> m a) -> [a] -> m a
The
foldl1Ais likefoldlAbut 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 actperforms the actionntimes, gathering the results.
- replicateA_
: Applicative m => Int -> m a -> m ()
Like
replicateA, but discards the result.