1
1
mirror of https://github.com/anoma/juvix.git synced 2025-01-05 22:46:08 +03:00
juvix/tests/positive/Internal/Case.juvix
janmasrovira 929a8658ac
Special syntax for case (#1800)
- Closes #1716

---------

Co-authored-by: Paul Cadman <git@paulcadman.dev>
2023-02-06 14:53:35 +01:00

36 lines
737 B
Plaintext

module Case;
open import Stdlib.Prelude;
isZero : Nat → Bool;
isZero n := case n
| zero := true
| k@(suc _) := false;
id' : Bool → {A : Type} → A → A;
id' b := case b
| true := id
| false := id;
pred : Nat → Nat;
pred n := case n
| zero := zero
| suc n := n;
appIf : {A : Type} → Bool → (A → A) → A → A;
appIf b f := case b
| true := f
| false := id;
appIf2 : {A : Type} → Bool → (A → A) → A → A;
appIf2 b f a := (case b
| true := f
| false := id)
a;
nestedCase1 : {A : Type} → Bool → (A → A) → A → A;
nestedCase1 b f := case b
| true := (case b
| _ := id)
| false := id;
end;