-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defining functions that take no arguments or multiple at once #180
Comments
We also briefly discussed (offline) the possibility of unifying the const $Function = def ('(anonymous)') And |
There are several exciting ideas here. I'm not yet sure what we should do, but it doesn't seem right for |
Are you still interested in this functionality, @Avaq? |
There's a lot of functionality, including this, I would like to have in order to achieve the broader goal of maturing sanctuary-def as a domain modelling tool. But because the scope of work to achieve this is so large, I tend to focus my attention elsewhere. |
Consider this function:
Currently
def
cannot express its type. I would like to explore changes to its API to allow for the definition of any sort of JavaScript function (except methods).More lists
The type could be encoded as a list of lists of
Type
s specifying function input, and a singleType
argument specifying output (we have to move it to a separate argument to keep the types consistent). So ourf
function could be defined as such:We can encode "multiple arguments at once" and "no arguments" by using the second level of lists. I like this solution, because the input specification mirrors function application exactly:
If we would go for this solution, my preference would be to make a change to the
$Function
-api to use the same approach to specifying its type. But this is not required.Taking a function definition as input
The
Type
there would have to be a Function type as defined by$Function
. Since$Function
is already capable of expressing complex function types by means of nesting, this would be sufficient to definef
:Additional thoughts
We won't necessarily have to change the
def
API. We can implementdef
on top of, say,defn
as a variant optimised for pure curried functions:The text was updated successfully, but these errors were encountered: