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 value- finalis- True, 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 - foldrAis analogous to- foldr, except that its result is encapsulated in an action. Note that- foldrAworks from right-to-left over the list arguments.
- foldr1A
- : Action m => (a -> a -> m a) -> [a] -> m a - foldr1Ais like- foldrAbut raises an error when presented with an empty list argument.
- foldlA
- : Action m => (b -> a -> m b) -> b -> [a] -> m b - foldlAis analogous to- foldl, except that its result is encapsulated in an action. Note that- foldlAworks from left-to-right over the list arguments.
- foldl1A
- : Action m => (a -> a -> m a) -> [a] -> m a - The - foldl1Ais like- foldlAbut 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 action- ntimes, gathering the results.
- replicateA_
- : Applicative m => Int -> m a -> m () - Like - replicateA, but discards the result.