Thoughts on function definitions
I was thinking that perhaps a nice syntax for function definitions would be to follow the steps of TS regarding syntax? Something where all function definitions are just lambdas? The rest of the signature stays the same.
This might look like contriving the syntax, but would actually make adoption easier for newcomers from the language
The example would look like
// v --- This equal sign is added, and this --- v
let f = (xs: List<Int>, p: (Int) => Bool): List<a> =>
effect {
let x = await xs
guard(p(x))
x.add(1).pure
}
I think that syntax is already supported (or maybe without a result type?). Definitely, if TS encourages that syntax, hinc should support it, thanks for the pointer!
I would prefer to keep both syntaxes, though, to cater also for people coming from Java and similar languages.
El El lun, 10 ago 2020 a las 12:12, Nick Tchayka [email protected] escribió:
I was thinking that perhaps a nice syntax for function definitions would be to follow the steps of TS regarding syntax? Something where all function definitions are just lambdas? The rest of the signature stays the same.
This might look like contriving the syntax, but would actually make adoption easier for newcomers from the language
The example would look like
// v --- This equal sign is added, and this --- vlet f = (xs: List<Int>, p: (Int) => Bool): List => effect { let x = await xs guard(p(x)) x.add(1).pure }
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/serras/hinc/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACLQVXVMSFU2LXPVMYUL5TR77BZ7ANCNFSM4PZZULGA .
-- Kind regards, Alejandro
Yep, that works without a result type.
For Java people we could implement function syntax, which would be desugared. I think that becoming something like a TS superset would benefit the project