summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPéter Diviánszky <divipp@gmail.com>2016-02-01 05:40:03 +0100
committerPéter Diviánszky <divipp@gmail.com>2016-02-01 05:40:03 +0100
commit15a113dc653a3c4fed667bc3689dc4f3b4fd4392 (patch)
tree4f151bd0063626951f78c4ac3435023f6603871e
parentf1293beb6ef4ee73701e5582c1050b7fd86330ea (diff)
annotate more closed expression
-rw-r--r--src/LambdaCube/Compiler/Infer.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/LambdaCube/Compiler/Infer.hs b/src/LambdaCube/Compiler/Infer.hs
index 9fdef49a..53cda1c7 100644
--- a/src/LambdaCube/Compiler/Infer.hs
+++ b/src/LambdaCube/Compiler/Infer.hs
@@ -114,6 +114,9 @@ conName a b c d = ConName a b c (get $ snd $ getParams d) d
114 where 114 where
115 get (TyCon s _) = s 115 get (TyCon s _) = s
116 116
117pattern Closed :: () => Up a => a -> a
118pattern Closed a <- a where Closed a = closedExp a
119
117pattern Con x n y <- Con_ _ x n y where Con x n y = Con_ (foldMap maxDB_ y) x n y 120pattern Con x n y <- Con_ _ x n y where Con x n y = Con_ (foldMap maxDB_ y) x n y
118pattern ConN s a <- Con (ConName s _ _ _ _) _ a 121pattern ConN s a <- Con (ConName s _ _ _ _) _ a
119pattern TCon s i t a <- Con (ConName s _ i _ t) _ a where TCon s i t a = Con (conName s Nothing i t) 0 a -- todo: don't match on type 122pattern TCon s i t a <- Con (ConName s _ i _ t) _ a where TCon s i t a = Con (conName s Nothing i t) 0 a -- todo: don't match on type
@@ -125,7 +128,7 @@ pattern TFun a t b <- Fun (FunName a _ t) b where TFun a t b = Fun (FunName a No
125pattern TFun' a t b <- Fun_ (FunName a _ t) b where TFun' a t b = Fun_ (FunName a Nothing t) b 128pattern TFun' a t b <- Fun_ (FunName a _ t) b where TFun' a t b = Fun_ (FunName a Nothing t) b
126pattern TyConN s a <- TyCon (TyConName s _ _ _ _ _) a 129pattern TyConN s a <- TyCon (TyConName s _ _ _ _ _) a
127pattern TTyCon s t a <- TyCon (TyConName s _ _ t _ _) a where TTyCon s t a = TyCon (TyConName s Nothing (error "todo: inum") t (error "todo: tcn cons 2") $ CaseFunName (error "TTyCon-A") (error "TTyCon-B") $ length a) a 130pattern TTyCon s t a <- TyCon (TyConName s _ _ t _ _) a where TTyCon s t a = TyCon (TyConName s Nothing (error "todo: inum") t (error "todo: tcn cons 2") $ CaseFunName (error "TTyCon-A") (error "TTyCon-B") $ length a) a
128pattern TTyCon0 s <- TyCon (TyConName s _ _ TType _ _) [] where TTyCon0 s = TyCon (TyConName s Nothing 0 TType (error "todo: tcn cons 3") $ CaseFunName (error "TTyCon0-A") (error "TTyCon0-B") 0) [] 131pattern TTyCon0 s <- TyCon (TyConName s _ _ TType _ _) [] where TTyCon0 s = Closed $ TyCon (TyConName s Nothing 0 TType (error "todo: tcn cons 3") $ CaseFunName (error "TTyCon0-A") (error "TTyCon0-B") 0) []
129pattern a :~> b = Pi Visible a b 132pattern a :~> b = Pi Visible a b
130 133
131pattern Unit = TTyCon0 "'Unit" 134pattern Unit = TTyCon0 "'Unit"
@@ -141,8 +144,8 @@ pattern TVec a b = TTyCon "'VecS" (TType :~> TNat :~> TType) [b, a]
141pattern Empty s <- TyCon (TyConName "'Empty" _ _ _ _ _) [EString s] where 144pattern Empty s <- TyCon (TyConName "'Empty" _ _ _ _ _) [EString s] where
142 Empty s = TyCon (TyConName "'Empty" Nothing (error "todo: inum2_") (TString :~> TType) (error "todo: tcn cons 3_") $ error "Empty") [EString s] 145 Empty s = TyCon (TyConName "'Empty" Nothing (error "todo: inum2_") (TString :~> TType) (error "todo: tcn cons 3_") $ error "Empty") [EString s]
143 146
144pattern TT = TCon "TT" 0 Unit [] 147pattern TT = Closed (TCon "TT" 0 Unit [])
145pattern Zero = TCon "Zero" 0 TNat [] 148pattern Zero = Closed (TCon "Zero" 0 TNat [])
146pattern Succ n = TCon "Succ" 1 (TNat :~> TNat) [n] 149pattern Succ n = TCon "Succ" 1 (TNat :~> TNat) [n]
147 150
148pattern CstrT t a b = TFun "'EqCT" (TType :~> Var 0 :~> Var 1 :~> TType) [t, a, b] 151pattern CstrT t a b = TFun "'EqCT" (TType :~> Var 0 :~> Var 1 :~> TType) [t, a, b]
@@ -159,8 +162,8 @@ pattern EInt a = ELit (LInt a)
159pattern EFloat a = ELit (LFloat a) 162pattern EFloat a = ELit (LFloat a)
160pattern EChar a = ELit (LChar a) 163pattern EChar a = ELit (LChar a)
161pattern EString a = ELit (LString a) 164pattern EString a = ELit (LString a)
162pattern EBool a <- (getEBool -> Just a) where EBool = mkBool 165pattern EBool a <- (getEBool -> Just a) where EBool = Closed . mkBool
163pattern ENat n <- (fromNatE -> Just n) where ENat = toNatE 166pattern ENat n <- (fromNatE -> Just n) where ENat = Closed . toNatE
164 167
165pattern LCon <- (isCon -> True) 168pattern LCon <- (isCon -> True)
166pattern CFun <- (isCaseFun -> True) 169pattern CFun <- (isCaseFun -> True)
@@ -204,7 +207,7 @@ isCon = \case
204 ELit _ -> True 207 ELit _ -> True
205 _ -> False 208 _ -> False
206 209
207mkOrdering = \case 210mkOrdering x = Closed $ case x of
208 LT -> TCon "LT" 0 TOrdering [] 211 LT -> TCon "LT" 0 TOrdering []
209 EQ -> TCon "EQ" 1 TOrdering [] 212 EQ -> TCon "EQ" 1 TOrdering []
210 GT -> TCon "GT" 2 TOrdering [] 213 GT -> TCon "GT" 2 TOrdering []