Pipe a Value Through Typed Steps
Write the code, see it run, pass the checks.
The problem
- hard
- Code
- Pro
Write pipe(value, f1, f2, f3): pass value through up to three functions, left to right, each getting the previous one's result, and return the last result (with no functions, return value itself). Use overloads so the result has the last step's type, each step's parameter is inferred from the step before (so inline arrow functions need no annotations), and a step that can't take the previous output is a type error.
Your code must pass
- Runs the steps left to right
- Passes each step the previous result
- Returns the value when there are no steps
- Has no type errors
- Returns the last step's type
- Each step gets the previous step's output
- Rejects a step that doesn't fit