parameterise over qty semiring

This commit is contained in:
rhiannon morris 2023-01-08 20:44:25 +01:00
parent 961c8415b5
commit c45a963ba0
16 changed files with 712 additions and 491 deletions

View file

@ -1,7 +1,7 @@
module TermImpls
import Quox.Syntax
import Quox.Pretty
import public Quox.Pretty
private
@ -22,7 +22,7 @@ eqSubst (_ ::: _) (Shift _) = Nothing
mutual
export covering
Eq (Term d n) where
Eq q => Eq (Term q d n) where
TYPE k == TYPE l = k == l
TYPE _ == _ = False
@ -49,7 +49,7 @@ mutual
DCloT {} == _ = False
export covering
Eq (Elim d n) where
Eq q => Eq (Elim q d n) where
F x == F y = x == y
F _ == _ = False
@ -75,16 +75,16 @@ mutual
DCloE {} == _ = False
export covering
Eq (ScopeTerm d n) where
Eq q => Eq (ScopeTerm q d n) where
TUsed s == TUsed t = s == t
TUnused s == TUnused t = s == t
TUsed _ == TUnused _ = False
TUnused _ == TUsed _ = False
export covering
Show (Term d n) where
PrettyHL q => Show (Term q d n) where
showPrec d t = showParens (d /= Open) $ prettyStr True t
export covering
Show (Elim d n) where
PrettyHL q => Show (Elim q d n) where
showPrec d e = showParens (d /= Open) $ prettyStr True e

View file

@ -2,10 +2,11 @@ module Tests.Equal
import Quox.Equal as Lib
import Quox.Pretty
import Quox.Syntax.Qty.Three
import TAP
export
ToInfo Error where
ToInfo (Error Three) where
toInfo (NotInScope x) =
[("type", "NotInScope"),
("name", show x)]
@ -35,10 +36,11 @@ ToInfo Error where
("right", prettyStr True rh)]
M = ReaderT Definitions (Either Error)
0 M : Type -> Type
M = ReaderT (Definitions Three) (Either (Error Three))
parameters (label : String) (act : Lazy (M ()))
{default empty globals : Definitions}
{default empty globals : Definitions Three}
testEq : Test
testEq = test label $ runReaderT globals act
@ -46,19 +48,19 @@ parameters (label : String) (act : Lazy (M ()))
testNeq = testThrows label (const True) $ runReaderT globals act
subT : {default 0 d, n : Nat} -> Term d n -> Term d n -> M ()
subT : {default 0 d, n : Nat} -> Term Three d n -> Term Three d n -> M ()
subT = Lib.subT
%hide Lib.subT
equalT : {default 0 d, n : Nat} -> Term d n -> Term d n -> M ()
equalT : {default 0 d, n : Nat} -> Term Three d n -> Term Three d n -> M ()
equalT = Lib.equalT
%hide Lib.equalT
subE : {default 0 d, n : Nat} -> Elim d n -> Elim d n -> M ()
subE : {default 0 d, n : Nat} -> Elim Three d n -> Elim Three d n -> M ()
subE = Lib.subE
%hide Lib.subE
equalE : {default 0 d, n : Nat} -> Elim d n -> Elim d n -> M ()
equalE : {default 0 d, n : Nat} -> Elim Three d n -> Elim Three d n -> M ()
equalE = Lib.equalE
%hide Lib.equalE

View file

@ -1,6 +1,7 @@
module Tests.Reduce
import Quox.Syntax as Lib
import Quox.Syntax.Qty.Three
import TermImpls
import TAP
@ -22,17 +23,18 @@ testNoStep step label e = test "\{label} (no step)" $
Right e' => with Prelude.(::) Left [("reduced", e')]
parameters {default 0 d, n : Nat}
testWhnfT : String -> Term d n -> Term d n -> Test
testWhnfT : String -> Term Three d n -> Term Three d n -> Test
testWhnfT = testWhnf whnfT
testWhnfE : String -> Elim d n -> Elim d n -> Test
testWhnfE : String -> Elim Three d n -> Elim Three d n -> Test
testWhnfE = testWhnf whnfE
testNoStepE : String -> Elim d n -> Test
testNoStepE : String -> Elim Three d n -> Test
testNoStepE = testNoStep stepE
testNoStepT : String -> Term d n -> Test
testNoStepT : String -> Term Three d n -> Test
testNoStepT = testNoStep stepT