-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Description
Greetings! I was wondering if it's possible to implement a simple one argument curry function in a type safe way using new generics capabilities.
---???
local function curry(f, first)
return function(...)
return f(first, ...)
end
end
-- func should evaluate as fun(y: number): number
local func = curry(math.pow)The first limitation I encountered is incorrect type evaluation when returning an alias from a function, e.g. Parameters.
---@generic F: function
---@param f F
---@return Parameters<F>
function return_params(f) end
--evaluates to `P` instead of (number, number)
local result = return_params(math.pow)Metadata
Metadata
Assignees
Labels
No labels