Binds
Idiomatic Nix bind helpers
bindAttrs
Like a bind-chain but operates over named attrset of required-effects.
bind.attrs { foo = 99; bar = pure 22; baz = asks (env: env.baz); }
Values that are non-effects become send params: send "foo" 99.
Result has same attr-keys with corresponding effect result.
See also: bind.comp, bind.fn for which this is the foundation.
NOTE: Ordering of chained effects.
Since an attrSet has no order, this function chains effects in
same order as builtins.attrNames (alphabetical). If you need
an special order for computations that might be order senstive,
specify a __sort = names => names function.
bindComp
Turns a Nix effectful function into an effect chain via bindAttrs.
bindComp { bar = pure 22; } ({ foo, bar }: pure (foo * bar))
The function sees bar as the result of pure 22 and foo as the
result of send "foo" false -- false comes directly from using
lib.functionArgs f, the handler can know if "foo" is optional in f.
This works by using bindAttrs on the intersection of function args
and attrs.
bindFn
Like bindComp but works on normal Nix functions and turns its result into a pure-effect.
bindFn { bar = pure 22; } ({ foo, bar }: foo * bar)