1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-29 10:33:15 +03:00
juvix/app/Commands/Dev/Nockma
Paul Cadman be24abb0ca
Support compilation to Anoma compatible functions (#2652)
This PR adds a `anoma` target to the `juvix compile`. This target
compiles a Juvix `main` function to a Nockma/Anoma "function". Unlike
the native, wasm, and nockma targets the main function may have any type
signature.

## Anoma calling convention

[Anoma calls
functions](6a4e15fe9c/lib/anoma/resource.ex (L122))
by evaluating the formula `[call L replace [RL args] @ S]` against a
subject equal to the function. Here `args` is a Nockma term that
evaluates to a tuple of arguments that should be passed to the function.

The anoma target compiles the `main` function to Nockma in the same way
as the nockma target. The main function is then
[wrapped](9a658465ae/src/Juvix/Compiler/Nockma/Translation/FromTree.hs (L627))
to make it compatible with the Anoma calling convention.

## Testing

The anoma calling convention is [unit
tested](9a658465ae/test/Nockma/Eval/Positive.hs (L117))
and [smoke
tested](9a658465ae/tests/smoke/Commands/compile.smoke.yaml (L159)).

This PR also adds versions of the end-to-end compilation tests. Most
tests are included, tests for builtin IO operations and string builtins
are omitted. Other tests that use Strings have been adapted to use other
types that are compatible with this backend.

## Nockma REPL

To facilitate testing the Nockma REPL can now load a nockma file as an
initial subject.

---------

Co-authored-by: Lukasz Czajka <lukasz@heliax.dev>
2024-02-23 12:54:22 +00:00
..
Eval Nockma compile (#2570) 2024-01-17 11:15:38 +01:00
Format Add dev nockma format command (#2593) 2024-01-29 13:36:53 +01:00
Repl Support compilation to Anoma compatible functions (#2652) 2024-02-23 12:54:22 +00:00
Eval.hs Refactor readFile and some parsers to use Path instead of FilePath (#2649) 2024-02-19 17:33:58 +01:00
Format.hs Refactor readFile and some parsers to use Path instead of FilePath (#2649) 2024-02-19 17:33:58 +01:00
Options.hs Add dev nockma format command (#2593) 2024-01-29 13:36:53 +01:00
Repl.hs Support compilation to Anoma compatible functions (#2652) 2024-02-23 12:54:22 +00:00