diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-02-01 05:40:03 +0100 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-02-01 05:40:03 +0100 |
commit | 15a113dc653a3c4fed667bc3689dc4f3b4fd4392 (patch) | |
tree | 4f151bd0063626951f78c4ac3435023f6603871e | |
parent | f1293beb6ef4ee73701e5582c1050b7fd86330ea (diff) |
annotate more closed expression
-rw-r--r-- | src/LambdaCube/Compiler/Infer.hs | 15 |
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 | ||
117 | pattern Closed :: () => Up a => a -> a | ||
118 | pattern Closed a <- a where Closed a = closedExp a | ||
119 | |||
117 | pattern Con x n y <- Con_ _ x n y where Con x n y = Con_ (foldMap maxDB_ y) x n y | 120 | pattern Con x n y <- Con_ _ x n y where Con x n y = Con_ (foldMap maxDB_ y) x n y |
118 | pattern ConN s a <- Con (ConName s _ _ _ _) _ a | 121 | pattern ConN s a <- Con (ConName s _ _ _ _) _ a |
119 | pattern 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 | 122 | pattern 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 | |||
125 | pattern TFun' a t b <- Fun_ (FunName a _ t) b where TFun' a t b = Fun_ (FunName a Nothing t) b | 128 | pattern TFun' a t b <- Fun_ (FunName a _ t) b where TFun' a t b = Fun_ (FunName a Nothing t) b |
126 | pattern TyConN s a <- TyCon (TyConName s _ _ _ _ _) a | 129 | pattern TyConN s a <- TyCon (TyConName s _ _ _ _ _) a |
127 | pattern 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 | 130 | pattern 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 |
128 | pattern 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) [] | 131 | pattern 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) [] |
129 | pattern a :~> b = Pi Visible a b | 132 | pattern a :~> b = Pi Visible a b |
130 | 133 | ||
131 | pattern Unit = TTyCon0 "'Unit" | 134 | pattern Unit = TTyCon0 "'Unit" |
@@ -141,8 +144,8 @@ pattern TVec a b = TTyCon "'VecS" (TType :~> TNat :~> TType) [b, a] | |||
141 | pattern Empty s <- TyCon (TyConName "'Empty" _ _ _ _ _) [EString s] where | 144 | pattern 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 | ||
144 | pattern TT = TCon "TT" 0 Unit [] | 147 | pattern TT = Closed (TCon "TT" 0 Unit []) |
145 | pattern Zero = TCon "Zero" 0 TNat [] | 148 | pattern Zero = Closed (TCon "Zero" 0 TNat []) |
146 | pattern Succ n = TCon "Succ" 1 (TNat :~> TNat) [n] | 149 | pattern Succ n = TCon "Succ" 1 (TNat :~> TNat) [n] |
147 | 150 | ||
148 | pattern CstrT t a b = TFun "'EqCT" (TType :~> Var 0 :~> Var 1 :~> TType) [t, a, b] | 151 | pattern 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) | |||
159 | pattern EFloat a = ELit (LFloat a) | 162 | pattern EFloat a = ELit (LFloat a) |
160 | pattern EChar a = ELit (LChar a) | 163 | pattern EChar a = ELit (LChar a) |
161 | pattern EString a = ELit (LString a) | 164 | pattern EString a = ELit (LString a) |
162 | pattern EBool a <- (getEBool -> Just a) where EBool = mkBool | 165 | pattern EBool a <- (getEBool -> Just a) where EBool = Closed . mkBool |
163 | pattern ENat n <- (fromNatE -> Just n) where ENat = toNatE | 166 | pattern ENat n <- (fromNatE -> Just n) where ENat = Closed . toNatE |
164 | 167 | ||
165 | pattern LCon <- (isCon -> True) | 168 | pattern LCon <- (isCon -> True) |
166 | pattern CFun <- (isCaseFun -> True) | 169 | pattern CFun <- (isCaseFun -> True) |
@@ -204,7 +207,7 @@ isCon = \case | |||
204 | ELit _ -> True | 207 | ELit _ -> True |
205 | _ -> False | 208 | _ -> False |
206 | 209 | ||
207 | mkOrdering = \case | 210 | mkOrdering 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 [] |