mirror of
https://github.com/anoma/juvix.git
synced 2024-12-04 06:23:13 +03:00
161a34c36b
* Closes #2769 * Removes old case syntax * Pretty printing doesn't print braces in `case` if the `case` is a "top" expression in a definition.
61 lines
1.0 KiB
Plaintext
61 lines
1.0 KiB
Plaintext
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';
|