The desired final typescript code is:
transform(input)(transformation1)(transformation2)(...
// input is any data, e.g. string or object
// transformationX should be a transforming function
I've wrote the code below so far, and I feel like I am inventing the wheel, i.e. something like this must be already implemented in FP, but I don't know how it is called. Can anyone tell which tool from https://gcanti.github.io/fp-ts/ can be used instead?
type Transformer = (transformation: Transformation) => Transformer
type Transformation = (input: object) => Transformer
const TranformerCreator = (input: object): Transformer
=> (transformation: Transformation): Transformer
=> transformation(input)
const transform: Transformation = (input: object) => {
return TranformerCreator(input)
}
const transformation1: Transformation = (input: object) => {
// do sometging with input
return TranformerCreator(input)
}