1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-06 00:16:14 +03:00
juvix/tests/Rust/Compilation/positive/test015.juvix
Łukasz Czajka 55598e0f95
Rust backend (#2787)
* Implements code generation through Rust.
* CLI: adds two `dev` compilation targets: 
  1. `rust` for generating Rust code
  2. `native-rust` for generating a native executable via Rust
* Adds end-to-end tests for compilation from Juvix to native executable
via Rust.
* A target for RISC0 needs to be added in a separate PR building on this
one.
2024-05-29 13:34:04 +02:00

44 lines
583 B
Plaintext

-- local functions with free variables
module test015;
import Stdlib.Prelude open;
terminating
f : Nat → Nat → Nat
| x :=
let
g (y : Nat) : Nat := x + y;
in if
(x == 0)
(f 10)
(if (x < 10) λ {y := g (f (sub x 1) y)} g);
g (x : Nat) (h : Nat → Nat) : Nat := x + h x;
terminating
h : Nat → Nat
| zero := 0
| (suc x) := g x h;
main : Nat :=
f 100 500
+ -- 600
f
5
0
+ -- 25
f
5
5
+ -- 30
h
10
+ -- 45
g
10
h
+ -- 55
g
3
(f 10);