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

Morphir-Elm Interpreter fails with first-class or partially applied functions #1139

Open
edwardpeters opened this issue Feb 8, 2024 · 0 comments
Labels
task Task level project item

Comments

@edwardpeters
Copy link

edwardpeters commented Feb 8, 2024

Describe the bug
The morphir-elm based interpreter frequently fails to work with first class or higher order functions; in particular, it reliably fails whenever a first class function relies on anything from lexical scope.

To Reproduce
The following code works in native elm:

type MyEnum = TwoArg Int Int

unable_to_compute : Int -> MyEnum
unable_to_compute x = 
    let 
        inner = 
            let y = 5 in \z -> TwoArg y z
    in
        inner x

wrong_result : Int -> MyEnum
wrong_result x = 
    let 
        inner = TwoArg 5
    in
        inner x

In the morphir-elm interpreter, "unable_to_compute", as the name would imply, is unable to be computed. "wrong result" meanwhile ignores its input argument and results in "TwoArg 5".

Expected behavior
I would expect the behavior to match elm, with first-class functions maintaining locally scoped variables.

Desktop (please complete the following information):

  • OS:OSX
  • Browser Chrome
  • Version 2.89.0

Additional context
This may be relevant to the morphir-scala discussion on RTValue, MDM and IR at finos/morphir-scala#529

@edwardpeters edwardpeters added the task Task level project item label Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
task Task level project item
Projects
None yet
Development

No branches or pull requests

1 participant