hinc icon indicating copy to clipboard operation
hinc copied to clipboard

Thoughts on function definitions

Open NickSeagull opened this issue 5 years ago • 2 comments

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
  }

NickSeagull avatar Aug 10 '20 10:08 NickSeagull

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

serras avatar Aug 10 '20 10:08 serras

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

NickSeagull avatar Aug 10 '20 10:08 NickSeagull