1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-12 14:28:08 +03:00
juvix/tests/Rust/Compilation/positive/test071.juvix

44 lines
1.1 KiB
Plaintext
Raw Normal View History

-- Named application
module test071;
import Stdlib.Data.Nat open hiding {Ord; mkOrd};
import Stdlib.Data.Nat.Ord as Ord;
import Stdlib.Data.Product as Ord;
import Stdlib.Data.Bool.Base open;
import Stdlib.Trait.Ord open using {Ordering; LT; EQ; GT; isLT; isGT};
trait
type Ord A :=
mkOrd {
cmp : A -> A -> Ordering;
lt : A -> A -> Bool;
ge : A -> A -> Bool
};
mkOrdHelper
{A}
(cmp : A -> A -> Ordering)
{lt : A -> A -> Bool := λ {a b := isLT (cmp a b)}}
{gt : A -> A -> Bool := λ {a b := isGT (cmp a b)}}
: Ord A :=
mkOrd cmp lt gt;
instance
ordNat : Ord Nat := mkOrdHelper@{
cmp (x y : Nat) : Ordering := Ord.compare x y
};
fun {a : Nat := 1} {b : Nat := a + 1} {c : Nat := b + a + 1}
: Nat := a * b + c;
f {a : Nat := 2} {b : Nat := a + 1} {c : Nat} : Nat := a * b * c;
g {a : Nat := 2} {b : Nat := a + 1} (c : Nat) : Nat := a * b * c;
h {a : Nat := 2} (b c : Nat) {d : Nat := 3} : Nat := a * b + c * d;
main : Nat :=
fun@{a := fun; b := fun@{b := 3} * fun@{b := fun {2}}} +
f@{c := 5} + g@?{b := 4} 3 + if (Ord.lt 1 0) 1 0 +
h@?{b := 4} 1;