qi icon indicating copy to clipboard operation
qi copied to clipboard

Global side effects and monads

Open countvajhula opened this issue 3 years ago • 0 comments

At the moment, Qi supports local side effects that receive the same inputs as the annotated flows and which do not affect the functioning of those flows.

In addition, we would like to support global side effects that can be specified in one place in reference to a flow such that every component of the flow inherits the side effect.

The simplest version of this could be where the side effects compose trivially by virtue of not propagating any outputs -- similar to the way local side effects behave now, where the output is simply grounded. This could be used, for instance, to attach a (>< displayln) side effect to every component of the flow in one place.

But it would be even more useful if these side effects could themselves compose in useful ways, i.e. I think what we are looking for here is a way to encode monadic behavior within the flow specification.

This would likely involve specifying a set of lambdas corresponding to either bind/unit or join/map/unit, in order to define the composition semantics. We could either provide a dedicated implementation for Qi here, or possibly use the interfaces from the functional-lib package.

countvajhula avatar Jan 06 '22 08:01 countvajhula