A thought on function chaining with constant Arguments

I probably should have been more verbosel in my description. Storing constant values like 13 is obviously unnecessary.
The usage it is intended for is the following:

Suppose you have a KnowledgeBase which stores, well, knowledge about some data you want to process, relations between data, some classifiers or regressors. Arbitrary kinds of domain knowledge if you want.
Then you have a set of transformations which transform new data while applying you stored knowledge, so they all need your KnowledgeBase as input, as well as the input data after you applied the previous transformation.

So, you may have:
Your knowledge domain KB
and functions f1 to f5 which may for example do:

  • assess the validity of new input given previous knowledge
  • some filtering
  • applying classifiers which may or may not correspond to those in your KB
  • check if any of your stored knowledge applies to the new data, optionally shortcut
  • try to integrate the new data
  • check KB for consistency

I could of course put these things together in a big function in fixed order, but some of these operations may not be necessary, some may be missing, maybe someone has a good idea for additional functionality and wants to integrate it without breaking my functionality. So, breaking it up into small functions which can be composed is probably the best idea.
Then, I wanted to make composition more elegant, so as to not force users to write:

f5(f4(f3(f2(f1(data1, kb), kb), kb,) kb,), kb)
f5(f4(f3(f2(f1(data2, kb), kb), kb,) kb,), kb)

Instead:

pipeline = Compose(kb, [f1, f2, f3, f4, f5])
pipeline(data1)
pipeline(data2)

is much more readable, but current Chaining is not exactly sufficient to do this (I believe. There was a long discussion about the functionality of piping and Chaining in julia somewhere, it’s an open topic ).

The knowledge base should be stored, because every transformation may depend on the state of it and the processing of data2 may depend on the processing of data1. Also it enables querying the kb without keeping an external reference somewhere.

I hope this helps understanding.

1 Like