Skip to content
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

Support "local" functions in the Editor #4612

Closed
2 tasks
StachuDotNet opened this issue Nov 24, 2022 · 3 comments
Closed
2 tasks

Support "local" functions in the Editor #4612

StachuDotNet opened this issue Nov 24, 2022 · 3 comments

Comments

@StachuDotNet
Copy link
Member

It's often useful to define and then use a function 'inline':

let fn = \val -> ...
let items = List::filter original fn

You can currently define a Block and use it like this, but the editor only allows you to use it in functions that explicitly request a Block such as List::map (at least, as far as I can tell). For example, you can't currently do the following:

let increment = \i -> i + 1
let ten = increment 9

The new version of the language (in the backend) currently supports this, but the Editor does not.

TODOs:

  • design/discuss an interaction model
  • update Fluid to support this
@StachuDotNet
Copy link
Member Author

StachuDotNet commented Nov 24, 2022

In the meantime, one can define an applyBlock fn like this:
image

and then use it like

let increment = \i -> i + 1
let ten = applyFn increment 9

(at least, that's how I'm personally working around this limitation)

@pbiggar
Copy link
Member

pbiggar commented Nov 25, 2022

The new version of the language (in the backend) currently supports this, but the Editor does not.

I misunderstood the issue, apologies. I thought we were talking about calling higher-order functions with stdlib functions. Anyway, this isn't currently supported in the language. I guess it should probably be supported? I'd prefer folks used real functions in general but it's undeniable that local functions have their place.

So if we want this we'll need a semantics defined as well the interaction model (basically, a definition of what the AST would be, and what the interpreter would do. This is usually pretty simple, though we'll need to account for incompletes, errorrails and derrors).

Note that 9 |> increment should currently work.

@StachuDotNet
Copy link
Member Author

needs to be reassessed for modern day; folded into #5239, will reference this doc when it comes up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants