Curry a Two-Argument Function, Typed
Write the code, see it run, pass the checks.
The problem
- medium
- Code
Write curry2(fn): turn a function of two arguments, (a, b) => result, into one that takes them one at a time, a => b => result, calling fn only once both are given. The first step can be reused with different second arguments. Type it so the curried function keeps each argument's type and the result's type, so a wrong argument at either step is a type error.
Your code must pass
- Passes both arguments to fn in order
- Can reuse the first step
- Has no type errors
- Keeps each argument's type and the result's
- Rejects a wrong first argument
- Rejects a wrong second argument