1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-12 14:28:08 +03:00
juvix/tests/Rust/Compilation/positive/test053.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

37 lines
807 B
Plaintext

-- Inlining
module test053;
import Stdlib.Prelude open;
{-# inline: 2 #-}
mycompose : {A B C : Type} -> (B -> C) -> (A -> B) -> A -> C
| f g x := f (g x);
{-# inline: true #-}
myconst : {A B : Type} -> A -> B -> A
| x _ := x;
{-# inline: 1 #-}
myflip : {A B C : Type} -> (A -> B -> C) -> B -> A -> C
| f b a := f a b;
rumpa : {A : Type} -> (A -> A) -> A -> A
| {A} f a :=
let
{-# inline: 1 #-}
go : Nat -> A -> A
| zero a := a
| (suc _) a := f a;
{-# inline: false #-}
h (g : A -> A) : A := g a;
in h (go 10);
main : Nat :=
let
f : Nat -> Nat := mycompose λ {x := x + 1} λ {x := x * 2};
g : Nat -> Nat -> Nat := myflip myconst;
{-# inline: false #-}
myid : Nat -> Nat := λ {x := x};
in myid (f 3 + g 7 9 + rumpa myid 5);