1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-04 06:23:13 +03:00
juvix/tests/positive/Alias.juvix
Łukasz Czajka 161a34c36b
Optional braces in case syntax (#2778)
* Closes #2769 
* Removes old case syntax
* Pretty printing doesn't print braces in `case` if the `case` is a
"top" expression in a definition.
2024-05-22 18:14:03 +01:00

61 lines
1.0 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module Alias;
import Stdlib.Data.Fixity open;
-- aliases are allowed to forward reference
syntax alias Boolean := Bool;
syntax alias ⊥ := false;
syntax alias := true;
--- Truth value
type Bool :=
| false
| true;
not : Boolean -> Boolean
| ⊥ :=
| := ⊥;
not2 (b : Boolean) : Boolean :=
let
syntax alias yes := ;
syntax alias no := ⊥;
in case b of
| no := yes
| yes := no;
module ExportAlias;
syntax alias Binary := Bool;
syntax alias one := ;
syntax alias zero := ⊥;
end;
open ExportAlias;
syntax operator || logical;
|| : Binary -> Binary -> Binary
| zero b := b
| one _ := one;
syntax operator or none;
syntax alias or := ||;
syntax alias ||| := ||;
or3 (a b c : Binary) : Binary := or (or a b) c;
or3' (a b c : Binary) : Binary := (a ||| b) ||| c;
type Pair := mkPair Binary Binary;
syntax operator , pair;
syntax alias , := mkPair;
myPair : Pair := one, ⊥;
localAlias : Binary -> Binary
| b :=
let
syntax alias b' := b;
in b';