I'm trying to write a library where the input is an Array of functions where the output of each function is merged in with its input and then passed into the next function.
Basically similar to compose/flow/pipe
, but the input is always a single object and the output only specifies new properties.
EG:
(A) -> B,
(A & B) -> C,
(A & B & C) -> D
...
I was able to accomplish this, but I'm sure there must be a "cleaner" more functional way to do it with fp-ts
:
NOTES:
- The caller cannot be responsible for the "merging" the input and output. I need a interface that accepts the collection of functions in the form where each only returns it's component part.
- The input of functions must be type-safe, and ideally forgiving (declaring function that takes
(A & B & C)
with only(A & C)
should not throw a type error.