diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-02-19 15:26:24 +0100 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-02-19 15:26:24 +0100 |
commit | a287d5a79406ac9042c5ca9bbd6b52b192ca1eee (patch) | |
tree | e731090ef4f95ef7dbab282599b0b719fdcdd169 /src/LambdaCube | |
parent | a4b6b7bae563d8d2cfdbb5afc3bde594dad7f77b (diff) |
names have identifiers
Diffstat (limited to 'src/LambdaCube')
-rw-r--r-- | src/LambdaCube/Compiler/CoreToIR.hs | 2 | ||||
-rw-r--r-- | src/LambdaCube/Compiler/Infer.hs | 308 |
2 files changed, 205 insertions, 105 deletions
diff --git a/src/LambdaCube/Compiler/CoreToIR.hs b/src/LambdaCube/Compiler/CoreToIR.hs index 8c759ea4..29a2ab39 100644 --- a/src/LambdaCube/Compiler/CoreToIR.hs +++ b/src/LambdaCube/Compiler/CoreToIR.hs | |||
@@ -857,7 +857,7 @@ mkApp (ExpTV (Neut (I.App_ a b)) et vs) = Just (ExpTV (Neut a) t vs, head $ chai | |||
857 | where t = neutType' (mkEnv vs) a | 857 | where t = neutType' (mkEnv vs) a |
858 | mkApp _ = Nothing | 858 | mkApp _ = Nothing |
859 | 859 | ||
860 | mkFunc r@(ExpTV (I.Func n def nt xs) ty vs) | all (supType . tyOf) (r: xs') && n `notElem` ["typeAnn"] && all validChar n | 860 | mkFunc r@(ExpTV (I.Func (show -> n) def nt xs) ty vs) | all (supType . tyOf) (r: xs') && n `notElem` ["typeAnn"] && all validChar n |
861 | = Just (untick n, toExp (def, nt), tyOf r, xs') | 861 | = Just (untick n, toExp (def, nt), tyOf r, xs') |
862 | where | 862 | where |
863 | xs' = chain vs nt $ reverse xs | 863 | xs' = chain vs nt $ reverse xs |
diff --git a/src/LambdaCube/Compiler/Infer.hs b/src/LambdaCube/Compiler/Infer.hs index 13e18411..c593f607 100644 --- a/src/LambdaCube/Compiler/Infer.hs +++ b/src/LambdaCube/Compiler/Infer.hs | |||
@@ -28,9 +28,11 @@ module LambdaCube.Compiler.Infer | |||
28 | , nType, conType, neutType, neutType', appTy, mkConPars, makeCaseFunPars, makeCaseFunPars' | 28 | , nType, conType, neutType, neutType', appTy, mkConPars, makeCaseFunPars, makeCaseFunPars' |
29 | , MaxDB(..), unfixlabel | 29 | , MaxDB(..), unfixlabel |
30 | , ErrorMsg, showError | 30 | , ErrorMsg, showError |
31 | , FName (..) | ||
31 | ) where | 32 | ) where |
32 | 33 | ||
33 | import Data.Monoid | 34 | import Data.Monoid |
35 | import Data.Char | ||
34 | import Data.Maybe | 36 | import Data.Maybe |
35 | import Data.List | 37 | import Data.List |
36 | import qualified Data.Set as Set | 38 | import qualified Data.Set as Set |
@@ -72,31 +74,125 @@ data Neutral | |||
72 | | Delta (SData ([Exp] -> Exp)) -- not neut? | 74 | | Delta (SData ([Exp] -> Exp)) -- not neut? |
73 | deriving (Show) | 75 | deriving (Show) |
74 | 76 | ||
75 | data ConName = ConName SName Int{-ordinal number, e.g. Zero:0, Succ:1-} Type | 77 | data ConName = ConName FName Int{-ordinal number, e.g. Zero:0, Succ:1-} Type |
76 | 78 | ||
77 | data TyConName = TyConName SName Int{-num of indices-} Type [(ConName, Type)]{-constructors-} CaseFunName | 79 | data TyConName = TyConName FName Int{-num of indices-} Type [(ConName, Type)]{-constructors-} CaseFunName |
78 | 80 | ||
79 | data FunName = FunName SName (Maybe Exp) Type | 81 | data FunName = FunName FName (Maybe Exp) Type |
80 | 82 | ||
81 | data CaseFunName = CaseFunName SName Type Int{-num of parameters-} | 83 | data CaseFunName = CaseFunName FName Type Int{-num of parameters-} |
82 | 84 | ||
83 | data TyCaseFunName = TyCaseFunName SName Type | 85 | data TyCaseFunName = TyCaseFunName FName Type |
84 | 86 | ||
85 | type Type = Exp | 87 | type Type = Exp |
86 | type ExpType = (Exp, Type) | 88 | type ExpType = (Exp, Type) |
87 | type SExp2 = SExp' ExpType | 89 | type SExp2 = SExp' ExpType |
88 | 90 | ||
89 | instance Show ConName where show (ConName n _ _) = n | 91 | instance Show ConName where show (ConName n _ _) = show n |
90 | instance Eq ConName where ConName _ n _ == ConName _ n' _ = n == n' | 92 | instance Eq ConName where ConName _ n _ == ConName _ n' _ = n == n' |
91 | instance Show TyConName where show (TyConName n _ _ _ _) = n | 93 | instance Show TyConName where show (TyConName n _ _ _ _) = show n |
92 | instance Eq TyConName where TyConName n _ _ _ _ == TyConName n' _ _ _ _ = n == n' | 94 | instance Eq TyConName where TyConName n _ _ _ _ == TyConName n' _ _ _ _ = n == n' |
93 | instance Show FunName where show (FunName n _ _) = n | 95 | instance Show FunName where show (FunName n _ _) = show n |
94 | instance Eq FunName where FunName n _ _ == FunName n' _ _ = n == n' | 96 | instance Eq FunName where FunName n _ _ == FunName n' _ _ = n == n' |
95 | instance Show CaseFunName where show (CaseFunName n _ _) = caseName n | 97 | instance Show CaseFunName where show (CaseFunName n _ _) = CaseName $ show n |
96 | instance Eq CaseFunName where CaseFunName n _ _ == CaseFunName n' _ _ = n == n' | 98 | instance Eq CaseFunName where CaseFunName n _ _ == CaseFunName n' _ _ = n == n' |
97 | instance Show TyCaseFunName where show (TyCaseFunName n _) = MatchName n | 99 | instance Show TyCaseFunName where show (TyCaseFunName n _) = MatchName $ show n |
98 | instance Eq TyCaseFunName where TyCaseFunName n _ == TyCaseFunName n' _ = n == n' | 100 | instance Eq TyCaseFunName where TyCaseFunName n _ == TyCaseFunName n' _ = n == n' |
99 | 101 | ||
102 | data FName | ||
103 | = CFName !Int (SData String) | ||
104 | | FVecScalar | ||
105 | | FEqCT | FT2 | Fcoe | FparEval | Ft2C | FprimFix | ||
106 | | FUnit | ||
107 | | FInt | ||
108 | | FWord | ||
109 | | FNat | ||
110 | | FBool | ||
111 | | FFloat | ||
112 | | FString | ||
113 | | FChar | ||
114 | | FOrdering | ||
115 | | FVecS | ||
116 | | FEmpty | ||
117 | | FHList | ||
118 | | FEq | ||
119 | | FOrd | ||
120 | | FNum | ||
121 | | FSigned | ||
122 | | FComponent | ||
123 | | FIntegral | ||
124 | | FFloating | ||
125 | | FOutput | ||
126 | | FType | ||
127 | | FHCons | ||
128 | | FHNil | ||
129 | | FZero | ||
130 | | FSucc | ||
131 | | FFalse | ||
132 | | FTrue | ||
133 | | FLT | ||
134 | | FGT | ||
135 | | FEQ | ||
136 | | FTT | ||
137 | | FNil | ||
138 | | FCons | ||
139 | | FSplit | ||
140 | deriving (Eq, Ord) | ||
141 | |||
142 | -- todo: use module indentifier instead of hash | ||
143 | cFName mod i (RangeSI (Range l _), s) = fromMaybe (CFName n $ SData s) $ lookup s fntable | ||
144 | where | ||
145 | n = hash (sourceName l) * 2^32 + sourceLine l * 2^16 + sourceColumn l * 2^3 -- + i | ||
146 | hash = foldr (\c x -> ord c + x*2) 0 | ||
147 | |||
148 | fntable = | ||
149 | [ (,) "'VecScalar" FVecScalar | ||
150 | , (,) "'EqCT" FEqCT | ||
151 | , (,) "'T2" FT2 | ||
152 | , (,) "coe" Fcoe | ||
153 | , (,) "parEval" FparEval | ||
154 | , (,) "t2C" Ft2C | ||
155 | , (,) "primFix" FprimFix | ||
156 | , (,) "'Unit" FUnit | ||
157 | , (,) "'Int" FInt | ||
158 | , (,) "'Word" FWord | ||
159 | , (,) "'Nat" FNat | ||
160 | , (,) "'Bool" FBool | ||
161 | , (,) "'Float" FFloat | ||
162 | , (,) "'String" FString | ||
163 | , (,) "'Char" FChar | ||
164 | , (,) "'Ordering" FOrdering | ||
165 | , (,) "'VecS" FVecS | ||
166 | , (,) "'Empty" FEmpty | ||
167 | , (,) "'HList" FHList | ||
168 | , (,) "'Eq" FEq | ||
169 | , (,) "'Ord" FOrd | ||
170 | , (,) "'Num" FNum | ||
171 | , (,) "'Signed" FSigned | ||
172 | , (,) "'Component" FComponent | ||
173 | , (,) "'Integral" FIntegral | ||
174 | , (,) "'Floating" FFloating | ||
175 | , (,) "'Output" FOutput | ||
176 | , (,) "'Type" FType | ||
177 | , (,) "HCons" FHCons | ||
178 | , (,) "HNil" FHNil | ||
179 | , (,) "Zero" FZero | ||
180 | , (,) "Succ" FSucc | ||
181 | , (,) "False" FFalse | ||
182 | , (,) "True" FTrue | ||
183 | , (,) "LT" FLT | ||
184 | , (,) "GT" FGT | ||
185 | , (,) "EQ" FEQ | ||
186 | , (,) "TT" FTT | ||
187 | , (,) "Nil" FNil | ||
188 | , (,) "Cons" FCons | ||
189 | , (,) "'Split" FSplit | ||
190 | ] | ||
191 | |||
192 | instance Show FName where | ||
193 | show (CFName _ (SData s)) = s | ||
194 | show s = fromMaybe (error "show") $ lookup s $ map (\(a, b) -> (b, a)) fntable | ||
195 | |||
100 | -------------------------------------------------------------------------------- auxiliary functions and patterns | 196 | -------------------------------------------------------------------------------- auxiliary functions and patterns |
101 | 197 | ||
102 | infixl 2 `App`, `app_` | 198 | infixl 2 `App`, `app_` |
@@ -110,7 +206,6 @@ isNoLabelEnd _ = True | |||
110 | mconcat1 [] = mempty | 206 | mconcat1 [] = mempty |
111 | mconcat1 [x] = x | 207 | mconcat1 [x] = x |
112 | mconcat1 xs = notClosed --foldl1 (<>) xs | 208 | mconcat1 xs = notClosed --foldl1 (<>) xs |
113 | mconcat1' = mconcat | ||
114 | 209 | ||
115 | pattern Fun' f vs i xs n <- Fun_ _ f vs i xs n where Fun' f vs i xs n = Fun_ (mconcat1 $ map maxDB_ vs ++ map maxDB_ xs {- <> iterateN i lowerDB (maxDB_ n)-}) f vs i xs n | 210 | pattern Fun' f vs i xs n <- Fun_ _ f vs i xs n where Fun' f vs i xs n = Fun_ (mconcat1 $ map maxDB_ vs ++ map maxDB_ xs {- <> iterateN i lowerDB (maxDB_ n)-}) f vs i xs n |
116 | pattern Fun f i xs n = Fun' f [] i xs n | 211 | pattern Fun f i xs n = Fun' f [] i xs n |
@@ -161,29 +256,29 @@ pattern TTyCon0 s <- (unfixlabel -> TyCon (TyConName s _ TType _ _) []) | |||
161 | tTyCon0 s cs = Closed $ TyCon (TyConName s 0 TType (map ((,) (error "tTyCon0")) cs) $ CaseFunName (error "TTyCon0-A") (error "TTyCon0-B") 0) [] | 256 | tTyCon0 s cs = Closed $ TyCon (TyConName s 0 TType (map ((,) (error "tTyCon0")) cs) $ CaseFunName (error "TTyCon0-A") (error "TTyCon0-B") 0) [] |
162 | pattern a :~> b = Pi Visible a b | 257 | pattern a :~> b = Pi Visible a b |
163 | 258 | ||
164 | pattern Unit <- TTyCon0 "'Unit" where Unit = tTyCon0 "'Unit" [Unit] | 259 | pattern Unit <- TTyCon0 FUnit where Unit = tTyCon0 FUnit [Unit] |
165 | pattern TInt <- TTyCon0 "'Int" where TInt = tTyCon0 "'Int" $ error "cs 1" | 260 | pattern TInt <- TTyCon0 FInt where TInt = tTyCon0 FInt $ error "cs 1" |
166 | pattern TNat <- TTyCon0 "'Nat" where TNat = tTyCon0 "'Nat" $ error "cs 3" | 261 | pattern TNat <- TTyCon0 FNat where TNat = tTyCon0 FNat $ error "cs 3" |
167 | pattern TBool <- TTyCon0 "'Bool" where TBool = tTyCon0 "'Bool" $ error "cs 4" | 262 | pattern TBool <- TTyCon0 FBool where TBool = tTyCon0 FBool $ error "cs 4" |
168 | pattern TFloat <- TTyCon0 "'Float" where TFloat = tTyCon0 "'Float" $ error "cs 5" | 263 | pattern TFloat <- TTyCon0 FFloat where TFloat = tTyCon0 FFloat $ error "cs 5" |
169 | pattern TString <- TTyCon0 "'String" where TString = tTyCon0 "'String" $ error "cs 6" | 264 | pattern TString <- TTyCon0 FString where TString = tTyCon0 FString $ error "cs 6" |
170 | pattern TChar <- TTyCon0 "'Char" where TChar = tTyCon0 "'Char" $ error "cs 7" | 265 | pattern TChar <- TTyCon0 FChar where TChar = tTyCon0 FChar $ error "cs 7" |
171 | pattern TOrdering <- TTyCon0 "'Ordering" where TOrdering = tTyCon0 "'Ordering" $ error "cs 8" | 266 | pattern TOrdering <- TTyCon0 FOrdering where TOrdering = tTyCon0 FOrdering $ error "cs 8" |
172 | pattern TVec a b <- TyConN "'VecS" {-(TType :~> TNat :~> TType)-} [b, a] | 267 | pattern TVec a b <- TyConN FVecS {-(TType :~> TNat :~> TType)-} [b, a] |
173 | 268 | ||
174 | pattern Empty s <- TyCon (TyConName "'Empty" _ _ _ _) [EString s] where | 269 | pattern Empty s <- TyCon (TyConName FEmpty _ _ _ _) [EString s] where |
175 | Empty s = TyCon (TyConName "'Empty" (error "todo: inum2_") (TString :~> TType) (error "todo: tcn cons 3_") $ error "Empty") [EString s] | 270 | Empty s = TyCon (TyConName FEmpty (error "todo: inum2_") (TString :~> TType) (error "todo: tcn cons 3_") $ error "Empty") [EString s] |
176 | 271 | ||
177 | pattern TT <- ConN' _ _ where TT = Closed (tCon "TT" 0 Unit []) | 272 | pattern TT <- ConN' _ _ where TT = Closed (tCon FTT 0 Unit []) |
178 | pattern Zero <- ConN "Zero" _ where Zero = Closed (tCon "Zero" 0 TNat []) | 273 | pattern Zero <- ConN FZero _ where Zero = Closed (tCon FZero 0 TNat []) |
179 | pattern Succ n <- ConN "Succ" (n:_) where Succ n = tCon "Succ" 1 (TNat :~> TNat) [n] | 274 | pattern Succ n <- ConN FSucc (n:_) where Succ n = tCon FSucc 1 (TNat :~> TNat) [n] |
180 | 275 | ||
181 | pattern CstrT t a b = Neut (CstrT' t a b) | 276 | pattern CstrT t a b = Neut (CstrT' t a b) |
182 | pattern CstrT' t a b = TFun' "'EqCT" (TType :~> Var 0 :~> Var 1 :~> TType) [t, a, b] | 277 | pattern CstrT' t a b = TFun' FEqCT (TType :~> Var 0 :~> Var 1 :~> TType) [t, a, b] |
183 | pattern Coe a b w x = TFun "coe" (TType :~> TType :~> CstrT TType (Var 1) (Var 0) :~> Var 2 :~> Var 2) [a,b,w,x] | 278 | pattern Coe a b w x = TFun Fcoe (TType :~> TType :~> CstrT TType (Var 1) (Var 0) :~> Var 2 :~> Var 2) [a,b,w,x] |
184 | pattern ParEval t a b = TFun "parEval" (TType :~> Var 0 :~> Var 1 :~> Var 2) [t, a, b] | 279 | pattern ParEval t a b = TFun FparEval (TType :~> Var 0 :~> Var 1 :~> Var 2) [t, a, b] |
185 | pattern T2 a b = TFun "'T2" (TType :~> TType :~> TType) [a, b] | 280 | pattern T2 a b = TFun FT2 (TType :~> TType :~> TType) [a, b] |
186 | pattern CSplit a b c <- UFunN "'Split" [a, b, c] | 281 | pattern CSplit a b c <- UFunN FSplit [a, b, c] |
187 | 282 | ||
188 | pattern EInt a = ELit (LInt a) | 283 | pattern EInt a = ELit (LInt a) |
189 | pattern EFloat a = ELit (LFloat a) | 284 | pattern EFloat a = ELit (LFloat a) |
@@ -207,22 +302,22 @@ fromNatE' (unfixlabel -> Zero) = Just 0 | |||
207 | fromNatE' (unfixlabel -> Succ n) = (1 +) <$> fromNatE' n | 302 | fromNatE' (unfixlabel -> Succ n) = (1 +) <$> fromNatE' n |
208 | fromNatE' _ = Nothing | 303 | fromNatE' _ = Nothing |
209 | 304 | ||
210 | mkBool False = Closed $ tCon "False" 0 TBool [] | 305 | mkBool False = Closed $ tCon FFalse 0 TBool [] |
211 | mkBool True = Closed $ tCon "True" 1 TBool [] | 306 | mkBool True = Closed $ tCon FTrue 1 TBool [] |
212 | 307 | ||
213 | getEBool (unfixlabel -> ConN' 0 _) = Just False | 308 | getEBool (unfixlabel -> ConN' 0 _) = Just False |
214 | getEBool (unfixlabel -> ConN' 1 _) = Just True | 309 | getEBool (unfixlabel -> ConN' 1 _) = Just True |
215 | getEBool _ = Nothing | 310 | getEBool _ = Nothing |
216 | 311 | ||
217 | mkOrdering x = Closed $ case x of | 312 | mkOrdering x = Closed $ case x of |
218 | LT -> tCon "LT" 0 TOrdering [] | 313 | LT -> tCon FLT 0 TOrdering [] |
219 | EQ -> tCon "EQ" 1 TOrdering [] | 314 | EQ -> tCon FEQ 1 TOrdering [] |
220 | GT -> tCon "GT" 2 TOrdering [] | 315 | GT -> tCon FGT 2 TOrdering [] |
221 | 316 | ||
222 | conTypeName :: ConName -> TyConName | 317 | conTypeName :: ConName -> TyConName |
223 | conTypeName (ConName _ _ t) = case snd $ getParams t of TyCon n _ -> n | 318 | conTypeName (ConName _ _ t) = case snd $ getParams t of TyCon n _ -> n |
224 | 319 | ||
225 | outputType = tTyCon0 "'Output" $ error "cs 9" | 320 | outputType = tTyCon0 FOutput $ error "cs 9" |
226 | boolType = TBool | 321 | boolType = TBool |
227 | trueExp = EBool True | 322 | trueExp = EBool True |
228 | 323 | ||
@@ -437,10 +532,10 @@ evalCaseFun a b x = error $ "evalCaseFun: " ++ show (a, x) | |||
437 | 532 | ||
438 | evalTyCaseFun a b (FL c) = evalTyCaseFun a b c | 533 | evalTyCaseFun a b (FL c) = evalTyCaseFun a b c |
439 | evalTyCaseFun a b (Neut c) = TyCaseFun a b c | 534 | evalTyCaseFun a b (Neut c) = TyCaseFun a b c |
440 | evalTyCaseFun (TyCaseFunName "match'Type" ty) [_, t, f] TType = t | 535 | evalTyCaseFun (TyCaseFunName FType ty) (_: t: f: _) TType = t |
441 | evalTyCaseFun (TyCaseFunName n ty) [_, t, f] (TyCon (TyConName n' _ _ _ _) vs) | n == n' = foldl app_ t vs | 536 | evalTyCaseFun (TyCaseFunName n ty) (_: t: f: _) (TyCon (TyConName n' _ _ _ _) vs) | n == n' = foldl app_ t vs |
442 | --evalTyCaseFun (TyCaseFunName n ty) [_, t, f] (DFun (FunName n' _) vs) | n == n' = foldl app_ t vs -- hack | 537 | --evalTyCaseFun (TyCaseFunName n ty) [_, t, f] (DFun (FunName n' _) vs) | n == n' = foldl app_ t vs -- hack |
443 | evalTyCaseFun (TyCaseFunName n ty) [_, t, f] _ = f | 538 | evalTyCaseFun (TyCaseFunName n ty) (_: t: f: _) _ = f |
444 | 539 | ||
445 | evalCoe a b (FL x) d = evalCoe a b x d | 540 | evalCoe a b (FL x) d = evalCoe a b x d |
446 | evalCoe a b TT d = d | 541 | evalCoe a b TT d = d |
@@ -457,61 +552,64 @@ evalCoe a b t d = Coe a b t d | |||
457 | -} | 552 | -} |
458 | 553 | ||
459 | getFunDef s f = case s of | 554 | getFunDef s f = case s of |
460 | "unsafeCoerce" -> \case xs@[_, _, x] -> case x of x@FL{} -> x; Neut{} -> f xs; _ -> x | 555 | FEqCT -> \case (t: a: b: _) -> cstr t a b |
461 | "'EqCT" -> \case [t, a, b] -> cstr t a b | 556 | FT2 -> \case (a: b: _) -> t2 a b |
462 | "reflCstr" -> \case [a] -> TT | 557 | Ft2C -> \case (a: b: _) -> t2C a b |
463 | "coe" -> \case [a, b, t, d] -> evalCoe a b t d | 558 | Fcoe -> \case (a: b: t: d: _) -> evalCoe a b t d |
464 | "'T2" -> \case [a, b] -> t2 a b | 559 | FparEval -> \case (t: a: b: _) -> parEval t a b |
465 | "t2C" -> \case [a, b] -> t2C a b | ||
466 | "parEval" -> \case [t, a, b] -> parEval t a b | ||
467 | where | 560 | where |
468 | parEval _ (LabelEnd x) _ = LabelEnd x | 561 | parEval _ (LabelEnd x) _ = LabelEnd x |
469 | parEval _ _ (LabelEnd x) = LabelEnd x | 562 | parEval _ _ (LabelEnd x) = LabelEnd x |
470 | parEval t a b = ParEval t a b | 563 | parEval t a b = ParEval t a b |
564 | CFName _ (SData s) -> case s of | ||
565 | "unsafeCoerce" -> \case xs@(_: _: x: _) -> case x of x@FL{} -> x; Neut{} -> f xs; _ -> x | ||
566 | "reflCstr" -> \case (a: _) -> TT | ||
471 | 567 | ||
472 | "hlistNilCase" -> \case [_, x, unfixlabel -> Con n@(ConName _ 0 _) _ []] -> x; xs -> f xs | 568 | "hlistNilCase" -> \case (_: x: (unfixlabel -> Con n@(ConName _ 0 _) _ _): _) -> x; xs -> f xs |
473 | "hlistConsCase" -> \case [_, _, _, x, unfixlabel -> Con n@(ConName _ 1 _) _ [_, _, a, b]] -> x `app_` a `app_` b; xs -> f xs | 569 | "hlistConsCase" -> \case (_: _: _: x: (unfixlabel -> Con n@(ConName _ 1 _) _ (_: _: a: b: _)): _) -> x `app_` a `app_` b; xs -> f xs |
474 | 570 | ||
475 | -- general compiler primitives | 571 | -- general compiler primitives |
476 | "primAddInt" -> \case [EInt i, EInt j] -> EInt (i + j); xs -> f xs | 572 | "primAddInt" -> \case (EInt i: EInt j: _) -> EInt (i + j); xs -> f xs |
477 | "primSubInt" -> \case [EInt i, EInt j] -> EInt (i - j); xs -> f xs | 573 | "primSubInt" -> \case (EInt i: EInt j: _) -> EInt (i - j); xs -> f xs |
478 | "primModInt" -> \case [EInt i, EInt j] -> EInt (i `mod` j); xs -> f xs | 574 | "primModInt" -> \case (EInt i: EInt j: _) -> EInt (i `mod` j); xs -> f xs |
479 | "primSqrtFloat" -> \case [EFloat i] -> EFloat $ sqrt i; xs -> f xs | 575 | "primSqrtFloat" -> \case (EFloat i: _) -> EFloat $ sqrt i; xs -> f xs |
480 | "primRound" -> \case [EFloat i] -> EInt $ round i; xs -> f xs | 576 | "primRound" -> \case (EFloat i: _) -> EInt $ round i; xs -> f xs |
481 | "primIntToFloat" -> \case [EInt i] -> EFloat $ fromIntegral i; xs -> f xs | 577 | "primIntToFloat" -> \case (EInt i: _) -> EFloat $ fromIntegral i; xs -> f xs |
482 | "primIntToNat" -> \case [EInt i] -> ENat $ fromIntegral i; xs -> f xs | 578 | "primIntToNat" -> \case (EInt i: _) -> ENat $ fromIntegral i; xs -> f xs |
483 | "primCompareInt" -> \case [EInt x, EInt y] -> mkOrdering $ x `compare` y; xs -> f xs | 579 | "primCompareInt" -> \case (EInt x: EInt y: _) -> mkOrdering $ x `compare` y; xs -> f xs |
484 | "primCompareFloat" -> \case [EFloat x, EFloat y] -> mkOrdering $ x `compare` y; xs -> f xs | 580 | "primCompareFloat" -> \case (EFloat x: EFloat y: _) -> mkOrdering $ x `compare` y; xs -> f xs |
485 | "primCompareChar" -> \case [EChar x, EChar y] -> mkOrdering $ x `compare` y; xs -> f xs | 581 | "primCompareChar" -> \case (EChar x: EChar y: _) -> mkOrdering $ x `compare` y; xs -> f xs |
486 | "primCompareString" -> \case [EString x, EString y] -> mkOrdering $ x `compare` y; xs -> f xs | 582 | "primCompareString" -> \case (EString x: EString y: _) -> mkOrdering $ x `compare` y; xs -> f xs |
487 | 583 | ||
488 | -- LambdaCube 3D specific primitives | 584 | -- LambdaCube 3D specific primitives |
489 | "PrimGreaterThan" -> \case [t, _, _, _, _, _, _, x, y] | Just r <- twoOpBool (>) t x y -> r; xs -> f xs | 585 | "PrimGreaterThan" -> \case (t: _: _: _: _: _: _: x: y: _) | Just r <- twoOpBool (>) t x y -> r; xs -> f xs |
490 | "PrimGreaterThanEqual" -> \case [t, _, _, _, _, _, _, x, y] | Just r <- twoOpBool (>=) t x y -> r; xs -> f xs | 586 | "PrimGreaterThanEqual" -> \case (t: _: _: _: _: _: _: x: y: _) | Just r <- twoOpBool (>=) t x y -> r; xs -> f xs |
491 | "PrimLessThan" -> \case [t, _, _, _, _, _, _, x, y] | Just r <- twoOpBool (<) t x y -> r; xs -> f xs | 587 | "PrimLessThan" -> \case (t: _: _: _: _: _: _: x: y: _) | Just r <- twoOpBool (<) t x y -> r; xs -> f xs |
492 | "PrimLessThanEqual" -> \case [t, _, _, _, _, _, _, x, y] | Just r <- twoOpBool (<=) t x y -> r; xs -> f xs | 588 | "PrimLessThanEqual" -> \case (t: _: _: _: _: _: _: x: y: _) | Just r <- twoOpBool (<=) t x y -> r; xs -> f xs |
493 | "PrimEqualV" -> \case [t, _, _, _, _, _, _, x, y] | Just r <- twoOpBool (==) t x y -> r; xs -> f xs | 589 | "PrimEqualV" -> \case (t: _: _: _: _: _: _: x: y: _) | Just r <- twoOpBool (==) t x y -> r; xs -> f xs |
494 | "PrimNotEqualV" -> \case [t, _, _, _, _, _, _, x, y] | Just r <- twoOpBool (/=) t x y -> r; xs -> f xs | 590 | "PrimNotEqualV" -> \case (t: _: _: _: _: _: _: x: y: _) | Just r <- twoOpBool (/=) t x y -> r; xs -> f xs |
495 | "PrimEqual" -> \case [t, _, _, x, y] | Just r <- twoOpBool (==) t x y -> r; xs -> f xs | 591 | "PrimEqual" -> \case (t: _: _: x: y: _) | Just r <- twoOpBool (==) t x y -> r; xs -> f xs |
496 | "PrimNotEqual" -> \case [t, _, _, x, y] | Just r <- twoOpBool (/=) t x y -> r; xs -> f xs | 592 | "PrimNotEqual" -> \case (t: _: _: x: y: _) | Just r <- twoOpBool (/=) t x y -> r; xs -> f xs |
497 | "PrimSubS" -> \case [_, _, _, _, x, y] | Just r <- twoOp (-) x y -> r; xs -> f xs | 593 | "PrimSubS" -> \case (_: _: _: _: x: y: _) | Just r <- twoOp (-) x y -> r; xs -> f xs |
498 | "PrimSub" -> \case [_, _, x, y] | Just r <- twoOp (-) x y -> r; xs -> f xs | 594 | "PrimSub" -> \case (_: _: x: y: _) | Just r <- twoOp (-) x y -> r; xs -> f xs |
499 | "PrimAddS" -> \case [_, _, _, _, x, y] | Just r <- twoOp (+) x y -> r; xs -> f xs | 595 | "PrimAddS" -> \case (_: _: _: _: x: y: _) | Just r <- twoOp (+) x y -> r; xs -> f xs |
500 | "PrimAdd" -> \case [_, _, x, y] | Just r <- twoOp (+) x y -> r; xs -> f xs | 596 | "PrimAdd" -> \case (_: _: x: y: _) | Just r <- twoOp (+) x y -> r; xs -> f xs |
501 | "PrimMulS" -> \case [_, _, _, _, x, y] | Just r <- twoOp (*) x y -> r; xs -> f xs | 597 | "PrimMulS" -> \case (_: _: _: _: x: y: _) | Just r <- twoOp (*) x y -> r; xs -> f xs |
502 | "PrimMul" -> \case [_, _, x, y] | Just r <- twoOp (*) x y -> r; xs -> f xs | 598 | "PrimMul" -> \case (_: _: x: y: _) | Just r <- twoOp (*) x y -> r; xs -> f xs |
503 | "PrimDivS" -> \case [_, _, _, _, _, x, y] | Just r <- twoOp_ (/) div x y -> r; xs -> f xs | 599 | "PrimDivS" -> \case (_: _: _: _: _: x: y: _) | Just r <- twoOp_ (/) div x y -> r; xs -> f xs |
504 | "PrimDiv" -> \case [_, _, _, _, _, x, y] | Just r <- twoOp_ (/) div x y -> r; xs -> f xs | 600 | "PrimDiv" -> \case (_: _: _: _: _: x: y: _) | Just r <- twoOp_ (/) div x y -> r; xs -> f xs |
505 | "PrimModS" -> \case [_, _, _, _, _, x, y] | Just r <- twoOp_ modF mod x y -> r; xs -> f xs | 601 | "PrimModS" -> \case (_: _: _: _: _: x: y: _) | Just r <- twoOp_ modF mod x y -> r; xs -> f xs |
506 | "PrimMod" -> \case [_, _, _, _, _, x, y] | Just r <- twoOp_ modF mod x y -> r; xs -> f xs | 602 | "PrimMod" -> \case (_: _: _: _: _: x: y: _) | Just r <- twoOp_ modF mod x y -> r; xs -> f xs |
507 | "PrimNeg" -> \case [_, x] | Just r <- oneOp negate x -> r; xs -> f xs | 603 | "PrimNeg" -> \case (_: x: _) | Just r <- oneOp negate x -> r; xs -> f xs |
508 | "PrimAnd" -> \case [EBool x, EBool y] -> EBool (x && y); xs -> f xs | 604 | "PrimAnd" -> \case (EBool x: EBool y: _) -> EBool (x && y); xs -> f xs |
509 | "PrimOr" -> \case [EBool x, EBool y] -> EBool (x || y); xs -> f xs | 605 | "PrimOr" -> \case (EBool x: EBool y: _) -> EBool (x || y); xs -> f xs |
510 | "PrimXor" -> \case [EBool x, EBool y] -> EBool (x /= y); xs -> f xs | 606 | "PrimXor" -> \case (EBool x: EBool y: _) -> EBool (x /= y); xs -> f xs |
511 | "PrimNot" -> \case [TNat, _, _, EBool x] -> EBool $ not x; xs -> f xs | 607 | "PrimNot" -> \case (TNat: _: _: EBool x: _) -> EBool $ not x; xs -> f xs |
512 | 608 | ||
513 | _ -> f | 609 | _ -> f |
514 | 610 | ||
611 | _ -> f | ||
612 | |||
515 | cstr = f [] | 613 | cstr = f [] |
516 | where | 614 | where |
517 | f z ty a a' = f_ z (unfixlabel ty) (unfixlabel a) (unfixlabel a') | 615 | f z ty a a' = f_ z (unfixlabel ty) (unfixlabel a) (unfixlabel a') |
@@ -525,11 +623,11 @@ cstr = f [] | |||
525 | f_ (_: ns) typ{-down?-} (down 0 -> Just a) (down 0 -> Just a') = f ns typ a a' | 623 | f_ (_: ns) typ{-down?-} (down 0 -> Just a) (down 0 -> Just a') = f ns typ a a' |
526 | f_ ns TType (Pi h a b) (Pi h' a' b') | h == h' = t2 (f ns TType a a') (f ((a, a'): ns) TType b b') | 624 | f_ ns TType (Pi h a b) (Pi h' a' b') | h == h' = t2 (f ns TType a a') (f ((a, a'): ns) TType b b') |
527 | 625 | ||
528 | f_ [] TType (UFunN "'VecScalar" [a, b]) (UFunN "'VecScalar" [a', b']) = t2 (f [] TNat a a') (f [] TType b b') | 626 | f_ [] TType (UFunN FVecScalar [a, b]) (UFunN FVecScalar [a', b']) = t2 (f [] TNat a a') (f [] TType b b') |
529 | f_ [] TType (UFunN "'VecScalar" [a, b]) (TVec a' b') = t2 (f [] TNat a a') (f [] TType b b') | 627 | f_ [] TType (UFunN FVecScalar [a, b]) (TVec a' b') = t2 (f [] TNat a a') (f [] TType b b') |
530 | f_ [] TType (UFunN "'VecScalar" [a, b]) t@(TTyCon0 n) | isElemTy n = t2 (f [] TNat a (ENat 1)) (f [] TType b t) | 628 | f_ [] TType (UFunN FVecScalar [a, b]) t@(TTyCon0 n) | isElemTy n = t2 (f [] TNat a (ENat 1)) (f [] TType b t) |
531 | f_ [] TType (TVec a' b') (UFunN "'VecScalar" [a, b]) = t2 (f [] TNat a' a) (f [] TType b' b) | 629 | f_ [] TType (TVec a' b') (UFunN FVecScalar [a, b]) = t2 (f [] TNat a' a) (f [] TType b' b) |
532 | f_ [] TType t@(TTyCon0 n) (UFunN "'VecScalar" [a, b]) | isElemTy n = t2 (f [] TNat a (ENat 1)) (f [] TType b t) | 630 | f_ [] TType t@(TTyCon0 n) (UFunN FVecScalar [a, b]) | isElemTy n = t2 (f [] TNat a (ENat 1)) (f [] TType b t) |
533 | 631 | ||
534 | f_ [] typ a@Neut{} a' = CstrT typ a a' | 632 | f_ [] typ a@Neut{} a' = CstrT typ a a' |
535 | f_ [] typ a a'@Neut{} = CstrT typ a a' | 633 | f_ [] typ a a'@Neut{} = CstrT typ a a' |
@@ -544,10 +642,10 @@ cstr = f [] | |||
544 | ff ns tt@(Pi v t _) ((t1, t2'): ts) = t2 (f ns t t1 t2') $ ff ns (appTy tt t1) ts | 642 | ff ns tt@(Pi v t _) ((t1, t2'): ts) = t2 (f ns t t1 t2') $ ff ns (appTy tt t1) ts |
545 | ff ns t zs = error $ "ff: " -- ++ show (a, n, length xs', length $ mkConPars n typ) ++ "\n" ++ ppShow (nType a) ++ "\n" ++ ppShow (foldl appTy (nType a) $ mkConPars n typ) ++ "\n" ++ ppShow (zip xs xs') ++ "\n" ++ ppShow zs ++ "\n" ++ ppShow t | 643 | ff ns t zs = error $ "ff: " -- ++ show (a, n, length xs', length $ mkConPars n typ) ++ "\n" ++ ppShow (nType a) ++ "\n" ++ ppShow (foldl appTy (nType a) $ mkConPars n typ) ++ "\n" ++ ppShow (zip xs xs') ++ "\n" ++ ppShow zs ++ "\n" ++ ppShow t |
546 | 644 | ||
547 | isElemTy n = n `elem` ["'Bool", "'Float", "'Int"] | 645 | isElemTy n = n `elem` [FBool, FFloat, FInt] |
548 | 646 | ||
549 | t2C (unfixlabel -> TT) (unfixlabel -> TT) = TT | 647 | t2C (unfixlabel -> TT) (unfixlabel -> TT) = TT |
550 | t2C a b = TFun "t2C" (Unit :~> Unit :~> Unit) [a, b] | 648 | t2C a b = TFun Ft2C (Unit :~> Unit :~> Unit) [a, b] |
551 | 649 | ||
552 | t2 (unfixlabel -> Unit) a = a | 650 | t2 (unfixlabel -> Unit) a = a |
553 | t2 a (unfixlabel -> Unit) = a | 651 | t2 a (unfixlabel -> Unit) = a |
@@ -790,7 +888,7 @@ inferN_ tellTrace = infer where | |||
790 | = infer te $ x `SAppV` SLamV (STyped mempty (substTo (v+1) (Var 0) $ up 1 t, TType)) `SAppV` a `SAppV` b `SAppV` SVar siv v | 888 | = infer te $ x `SAppV` SLamV (STyped mempty (substTo (v+1) (Var 0) $ up 1 t, TType)) `SAppV` a `SAppV` b `SAppV` SVar siv v |
791 | -- temporal hack | 889 | -- temporal hack |
792 | | x@(SGlobal (si, CaseName "'VecS")) `SAppV` SLamV (SLamV (Wildcard _)) `SAppV` a `SAppV` b `SAppV` c `SAppV` SVar siv v <- e | 890 | | x@(SGlobal (si, CaseName "'VecS")) `SAppV` SLamV (SLamV (Wildcard _)) `SAppV` a `SAppV` b `SAppV` c `SAppV` SVar siv v <- e |
793 | , TyConN "'VecS" [_, Var n'] <- snd $ varType "xx" v te | 891 | , TyConN FVecS [_, Var n'] <- snd $ varType "xx" v te |
794 | = infer te $ x `SAppV` SLamV (SLamV (STyped mempty (substTo (n'+2) (Var 1) $ up 2 t, TType))) `SAppV` a `SAppV` b `SAppV` c `SAppV` SVar siv v | 892 | = infer te $ x `SAppV` SLamV (SLamV (STyped mempty (substTo (n'+2) (Var 1) $ up 2 t, TType))) `SAppV` a `SAppV` b `SAppV` c `SAppV` SVar siv v |
795 | 893 | ||
796 | {- | 894 | {- |
@@ -961,7 +1059,7 @@ replaceMetas bind = \case | |||
961 | 1059 | ||
962 | 1060 | ||
963 | isCstr CstrT{} = True | 1061 | isCstr CstrT{} = True |
964 | isCstr (UFunN s [_]) = s `elem` ["'Eq", "'Ord", "'Num", "'CNum", "'Signed", "'Component", "'Integral", "'NumComponent", "'Floating"] -- todo: use Constraint type to decide this | 1062 | isCstr (UFunN s [_]) = s `elem` [FEq, FOrd, FNum, FSigned, FComponent, FIntegral, FFloating] -- todo: use Constraint type to decide this |
965 | isCstr _ = {- trace_ (ppShow c ++ show c) $ -} False | 1063 | isCstr _ = {- trace_ (ppShow c ++ show c) $ -} False |
966 | 1064 | ||
967 | -------------------------------------------------------------------------------- re-checking | 1065 | -------------------------------------------------------------------------------- re-checking |
@@ -1117,12 +1215,14 @@ listTypeInfos m = map (second Set.toList) $ Map.toList $ Map.unionsWith (<>) [Ma | |||
1117 | 1215 | ||
1118 | -------------------------------------------------------------------------------- inference for statements | 1216 | -------------------------------------------------------------------------------- inference for statements |
1119 | 1217 | ||
1218 | modn = 0 | ||
1219 | |||
1120 | handleStmt :: MonadFix m => [Stmt] -> Stmt -> IM m GlobalEnv | 1220 | handleStmt :: MonadFix m => [Stmt] -> Stmt -> IM m GlobalEnv |
1121 | handleStmt defs = \case | 1221 | handleStmt defs = \case |
1122 | Primitive n (trSExp' -> t_) -> do | 1222 | Primitive n (trSExp' -> t_) -> do |
1123 | t <- inferType =<< ($ t_) <$> addF | 1223 | t <- inferType =<< ($ t_) <$> addF |
1124 | tellType (fst n) t | 1224 | tellType (fst n) t |
1125 | addToEnv n $ flip (,) t $ lamify t $ Neut . DFun_ (FunName (snd n) Nothing t) | 1225 | addToEnv n $ flip (,) t $ lamify t $ Neut . DFun_ (FunName (cFName modn 0 n) Nothing t) |
1126 | Let n mt t_ -> do | 1226 | Let n mt t_ -> do |
1127 | af <- addF | 1227 | af <- addF |
1128 | let t__ = maybe id (flip SAnn . af) mt t_ | 1228 | let t__ = maybe id (flip SAnn . af) mt t_ |
@@ -1156,7 +1256,7 @@ handleStmt defs = \case | |||
1156 | let pars = zipWith (\x -> second $ STyped (debugSI "mkConstr1") . flip (,) TType . up_ (1+j) x) [0..] $ drop (length ps) $ fst $ getParams cty | 1256 | let pars = zipWith (\x -> second $ STyped (debugSI "mkConstr1") . flip (,) TType . up_ (1+j) x) [0..] $ drop (length ps) $ fst $ getParams cty |
1157 | act = length . fst . getParams $ cty | 1257 | act = length . fst . getParams $ cty |
1158 | acts = map fst . fst . getParams $ cty | 1258 | acts = map fst . fst . getParams $ cty |
1159 | conn = ConName (snd cn) j cty | 1259 | conn = ConName (cFName modn 1 cn) j cty |
1160 | e <- addToEnv cn (Con conn 0 [], cty) | 1260 | e <- addToEnv cn (Con conn 0 [], cty) |
1161 | return (e, ((conn, cty) | 1261 | return (e, ((conn, cty) |
1162 | , addParamsS pars | 1262 | , addParamsS pars |
@@ -1170,8 +1270,8 @@ handleStmt defs = \case | |||
1170 | SPi Visible (apps' (SGlobal s) $ zip (map fst ps) (downToS "a6" inum $ length ps) ++ zip (map fst $ fst $ getParamsS t_) (downToS "a7" 0 inum)) SType | 1270 | SPi Visible (apps' (SGlobal s) $ zip (map fst ps) (downToS "a6" inum $ length ps) ++ zip (map fst $ fst $ getParamsS t_) (downToS "a7" 0 inum)) SType |
1171 | 1271 | ||
1172 | (e1, es, tcn, cfn@(CaseFunName _ ct _), _, _) <- mfix $ \ ~(_, _, _, _, ct', cons') -> do | 1272 | (e1, es, tcn, cfn@(CaseFunName _ ct _), _, _) <- mfix $ \ ~(_, _, _, _, ct', cons') -> do |
1173 | let cfn = CaseFunName (snd s) ct' $ length ps | 1273 | let cfn = CaseFunName (cFName modn 2 s) ct' $ length ps |
1174 | let tcn = TyConName (snd s) inum vty (map fst cons') cfn | 1274 | let tcn = TyConName (cFName modn 3 s) inum vty (map fst cons') cfn |
1175 | e1 <- addToEnv s (TyCon tcn [], vty) | 1275 | e1 <- addToEnv s (TyCon tcn [], vty) |
1176 | (unzip -> (mconcat -> es, cons)) <- withEnv e1 $ zipWithM mkConstr [0..] cs | 1276 | (unzip -> (mconcat -> es, cons)) <- withEnv e1 $ zipWithM mkConstr [0..] cs |
1177 | ct <- withEnv (e1 <> es) $ inferType | 1277 | ct <- withEnv (e1 <> es) $ inferType |
@@ -1193,7 +1293,7 @@ handleStmt defs = \case | |||
1193 | :~> TType | 1293 | :~> TType |
1194 | :~> Var 2 `app_` Var 0 | 1294 | :~> Var 2 `app_` Var 0 |
1195 | :~> Var 3 `app_` Var 1 | 1295 | :~> Var 3 `app_` Var 1 |
1196 | e3 <- addToEnv (fst s, MatchName (snd s)) (lamify t $ \[m, tr, n, f] -> evalTyCaseFun (TyCaseFunName (snd s) t) [m, tr, f] n, t) | 1296 | e3 <- addToEnv (fst s, MatchName (snd s)) (lamify t $ \[m, tr, n, f] -> evalTyCaseFun (TyCaseFunName (cFName modn 4 s) t) [m, tr, f] n, t) |
1197 | return (e1 <> e2 <> e3 <> es) | 1297 | return (e1 <> e2 <> e3 <> es) |
1198 | 1298 | ||
1199 | stmt -> error $ "handleStmt: " ++ show stmt | 1299 | stmt -> error $ "handleStmt: " ++ show stmt |
@@ -1203,12 +1303,12 @@ withEnv e = local $ second (<> e) | |||
1203 | mkELet n x xt = {-(if null vs then id else trace_ $ "mkELet " ++ show (length vs) ++ " " ++ show n)-} term | 1303 | mkELet n x xt = {-(if null vs then id else trace_ $ "mkELet " ++ show (length vs) ++ " " ++ show n)-} term |
1204 | where | 1304 | where |
1205 | vs = [Var i | i <- Set.toList $ free x <> free xt] | 1305 | vs = [Var i | i <- Set.toList $ free x <> free xt] |
1206 | fn = FunName (snd n) (Just x) xt | 1306 | fn = FunName (cFName modn 5 n) (Just x) xt |
1207 | 1307 | ||
1208 | term = pmLabel fn vs 0 [] $ getFix x 0 | 1308 | term = pmLabel fn vs 0 [] $ getFix x 0 |
1209 | 1309 | ||
1210 | getFix (Lam z) i = Lam $ getFix z (i+1) | 1310 | getFix (Lam z) i = Lam $ getFix z (i+1) |
1211 | getFix (TFun "primFix" _ [t, Lam f]) i = (if null vs then id else trace_ "!local rec") $ subst 0 (foldl app_ term (downTo 0 i)) f | 1311 | getFix (TFun FprimFix _ [t, Lam f]) i = (if null vs then id else trace_ "!local rec") $ subst 0 (foldl app_ term (downTo 0 i)) f |
1212 | getFix x _ = x | 1312 | getFix x _ = x |
1213 | 1313 | ||
1214 | 1314 | ||
@@ -1373,7 +1473,7 @@ instance MkDoc Exp where | |||
1373 | (getTTup -> Just xs) -> shTuple <$> mapM f xs | 1473 | (getTTup -> Just xs) -> shTuple <$> mapM f xs |
1374 | (getTup -> Just xs) -> shTuple <$> mapM f xs | 1474 | (getTup -> Just xs) -> shTuple <$> mapM f xs |
1375 | Con s _ xs -> foldl (shApp Visible) (shAtom_ $ show s) <$> mapM f xs | 1475 | Con s _ xs -> foldl (shApp Visible) (shAtom_ $ show s) <$> mapM f xs |
1376 | TyConN s xs -> foldl (shApp Visible) (shAtom_ s) <$> mapM f xs | 1476 | TyConN s xs -> foldl (shApp Visible) (shAtom_ $ show s) <$> mapM f xs |
1377 | TType -> pure $ shAtom "Type" | 1477 | TType -> pure $ shAtom "Type" |
1378 | ELit l -> pure $ shAtom $ show l | 1478 | ELit l -> pure $ shAtom $ show l |
1379 | Neut x -> mkDoc ts x | 1479 | Neut x -> mkDoc ts x |
@@ -1406,15 +1506,15 @@ instance MkDoc (CEnv Exp) where | |||
1406 | Meta a b -> join $ shLam True BMeta <$> mkDoc ts a <*> pure (f b) | 1506 | Meta a b -> join $ shLam True BMeta <$> mkDoc ts a <*> pure (f b) |
1407 | Assign i (x, _) e -> shLet i (mkDoc ts x) (f e) | 1507 | Assign i (x, _) e -> shLet i (mkDoc ts x) (f e) |
1408 | 1508 | ||
1409 | getTup (unfixlabel -> ConN "HCons" [_, _, x, xs]) = (x:) <$> getTup xs | 1509 | getTup (unfixlabel -> ConN FHCons [_, _, x, xs]) = (x:) <$> getTup xs |
1410 | getTup (unfixlabel -> ConN "HNil" []) = Just [] | 1510 | getTup (unfixlabel -> ConN FHNil []) = Just [] |
1411 | getTup _ = Nothing | 1511 | getTup _ = Nothing |
1412 | 1512 | ||
1413 | getTTup (unfixlabel -> TyConN "'HList" [xs]) = getList xs | 1513 | getTTup (unfixlabel -> TyConN FHList [xs]) = getList xs |
1414 | getTTup _ = Nothing | 1514 | getTTup _ = Nothing |
1415 | 1515 | ||
1416 | getList (unfixlabel -> ConN "Cons" [x, xs]) = (x:) <$> getList xs | 1516 | getList (unfixlabel -> ConN FCons [x, xs]) = (x:) <$> getList xs |
1417 | getList (unfixlabel -> ConN "Nil" []) = Just [] | 1517 | getList (unfixlabel -> ConN FNil []) = Just [] |
1418 | getList _ = Nothing | 1518 | getList _ = Nothing |
1419 | 1519 | ||
1420 | 1520 | ||