Idris2/tests/ttimp/basic002/Adder.yaff
Edwin Brady a972778eab Add test script
They don't all pass yet, for minor reasons. Coming shortly...
Unfortunately the startup overhead for chez is really noticeable here!
2020-05-19 18:25:18 +01:00

16 lines
311 B
Plaintext

data Nat : Type where
Z : Nat
S : Nat -> Nat
AdderTy : Nat -> Type
AdderTy Z = Nat
AdderTy (S $k) = Nat -> AdderTy k
plus : Nat -> Nat -> Nat
plus Z $y = y
plus (S $k) $y = S (plus k y)
adder : (i : Nat) -> (acc : Nat) -> AdderTy i
adder Z $acc = acc
adder (S $k) $acc = \x => adder k (plus x acc)