Skip to content

Commit

Permalink
Add some more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Ailrun committed Sep 6, 2024
1 parent 21cd300 commit 6a708d8
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
49 changes: 49 additions & 0 deletions examples/nary.mcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
(* main body *)
(
fun (Nary : forall (n : Nat) -> Type@0)
(appNary : forall (n : Nat) (f : Nary (succ n)) (arg : Nat) -> Nary n)
(toNat : forall (f : Nary 0) -> Nat)
(n : Nat)
(f : Nary n)
-> (rec n return y -> (forall (g : Nary y) -> Nat)
| zero => toNat
| succ m, r => fun (g : Nary (succ m)) -> r (appNary m g (succ m))
end) f
)
(* Nary definition *)
(
fun (n : Nat)
-> rec n return y -> Type@0
| zero => Nat
| succ m, r => forall (a : Nat) -> r
end
)
(* appNary definition *)
(
fun (n : Nat)
(f : rec succ n return y -> Type@0
| zero => Nat
| succ m, r => forall (a : Nat) -> r
end)
(arg : Nat)
-> f arg
)
(* toNat definition *)
(fun (f : Nat) -> f)
(* arguments n and f

This function sums up all its 3 inputs.
*)
3
(
(fun (add : forall (a : Nat) (b : Nat) -> Nat) -> (fun (a : Nat) (b : Nat) (c : Nat) -> add a (add b c)))
(
fun (a : Nat)
(b : Nat)
-> rec a return y -> Nat
| zero => b
| succ m, r => succ r
end
)
)
: Nat
1 change: 1 addition & 0 deletions examples/simple_nat.mcl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
succ 3 : Nat

0 comments on commit 6a708d8

Please sign in to comment.