Many => Any

This commit is contained in:
rhiannon morris 2021-09-03 17:56:04 +02:00
parent 6da33625f8
commit 5baade8dd5
1 changed files with 6 additions and 6 deletions

View File

@ -6,14 +6,14 @@ import Data.Fin
public export public export
data Qty = Zero | One | Many data Qty = Zero | One | Any
%name Qty.Qty pi, rh %name Qty.Qty pi, rh
private Repr : Type private Repr : Type
Repr = Fin 3 Repr = Fin 3
private %inline repr : Qty -> Repr private %inline repr : Qty -> Repr
repr pi = case pi of Zero => 0; One => 1; Many => 2 repr pi = case pi of Zero => 0; One => 1; Any => 2
export Eq Qty where (==) = (==) `on` repr export Eq Qty where (==) = (==) `on` repr
export Ord Qty where compare = compare `on` repr export Ord Qty where compare = compare `on` repr
@ -25,7 +25,7 @@ PrettyHL Qty where
case pi of case pi of
Zero => ifUnicode "𝟬" "0" Zero => ifUnicode "𝟬" "0"
One => ifUnicode "𝟭" "1" One => ifUnicode "𝟭" "1"
Many => ifUnicode "𝛚" "*" Any => ifUnicode "𝛚" "*"
export %inline export %inline
prettyQtyBinds : Pretty.HasEnv m => List Qty -> m (Doc HL) prettyQtyBinds : Pretty.HasEnv m => List Qty -> m (Doc HL)
@ -38,7 +38,7 @@ public export
(+) : Qty -> Qty -> Qty (+) : Qty -> Qty -> Qty
Zero + rh = rh Zero + rh = rh
pi + Zero = pi pi + Zero = pi
_ + _ = Many _ + _ = Any
public export public export
(*) : Qty -> Qty -> Qty (*) : Qty -> Qty -> Qty
@ -46,9 +46,9 @@ Zero * _ = Zero
_ * Zero = Zero _ * Zero = Zero
One * rh = rh One * rh = rh
pi * One = pi pi * One = pi
Many * Many = Many Any * Any = Any
infix 6 <=. infix 6 <=.
public export public export
(<=.) : Qty -> Qty -> Bool (<=.) : Qty -> Qty -> Bool
pi <=. rh = rh == Many || pi == rh pi <=. rh = rh == Any || pi == rh