summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPéter Diviánszky <divipp@gmail.com>2016-05-13 23:05:19 +0200
committerPéter Diviánszky <divipp@gmail.com>2016-05-13 23:05:19 +0200
commit935e60f12569f521216b56d8acf01de721e5168e (patch)
treec5992970c67adf4b9b17a4f2fb5f87c0cc6b2743 /src
parent8f2e602cada9141b653802cf1084b9bdfd6e0d06 (diff)
refactoring
Diffstat (limited to 'src')
-rw-r--r--src/LambdaCube/Compiler/Statements.hs20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/LambdaCube/Compiler/Statements.hs b/src/LambdaCube/Compiler/Statements.hs
index 3cd1edf1..2120efec 100644
--- a/src/LambdaCube/Compiler/Statements.hs
+++ b/src/LambdaCube/Compiler/Statements.hs
@@ -127,8 +127,7 @@ desugarValueDef p e = sequence
127 dns = reverse $ getPVars p 127 dns = reverse $ getPVars p
128 n = mangleNames dns 128 n = mangleNames dns
129 129
130--getLet (StmtLet x dx) = Just (x, dx) 130getLet (StmtLet x dx) = Just (x, dx)
131getLet (StLet x mt dx) = Just (x, mt, dx)
132getLet _ = Nothing 131getLet _ = Nothing
133 132
134fst' (x, _) = x -- TODO 133fst' (x, _) = x -- TODO
@@ -137,27 +136,18 @@ desugarMutual :: {-MonadWriter [ParseCheck] m => -} [Stmt] -> [Stmt]
137desugarMutual [x@Primitive{}] = [x] 136desugarMutual [x@Primitive{}] = [x]
138desugarMutual [x@Data{}] = [x] 137desugarMutual [x@Data{}] = [x]
139desugarMutual [x@PrecDef{}] = [x] 138desugarMutual [x@PrecDef{}] = [x]
140desugarMutual [StLet n nt nd] = [StLet n nt $ addFix n nt nd] 139desugarMutual [StLet n nt nd] = [StLet n nt $ addFix n nd]
141--desugarMutual [StmtLet n nd] = [StmtLet n $ addFix n nd] 140--desugarMutual [StmtLet n nd] = [StmtLet n $ addFix n nd] -- TODO
142desugarMutual (traverse getLet -> Just (unzip3 -> (ns, ts, ds))) = fst' $ runWriter $ do 141desugarMutual (traverse getLet -> Just (unzip -> (ns, ds))) = fst' $ runWriter $ do
143--desugarMutual (traverse getLet -> Just (unzip -> (ns, ds))) = fst' $ runWriter $ do
144 ss <- compileStmt'_ sLHS SRHS SRHS =<< desugarValueDef (foldr cHCons cHNil $ PVarSimp <$> ns) (SGlobal xy) 142 ss <- compileStmt'_ sLHS SRHS SRHS =<< desugarValueDef (foldr cHCons cHNil $ PVarSimp <$> ns) (SGlobal xy)
145 return $ 143 return $ StmtLet xy (addFix xy $ mkLets' SLet ss $ foldr HCons HNil ds) : ss
146-- StLet xy ty (addFix xy $ mkLets' SLet ss $ foldr HCons HNil ds) : ss
147 StLet xy ty (addFix xy ty $ mkLets' SLet ss $ foldr HCons HNil ds) : ss
148 144
149 where 145 where
150 ty = Nothing -- TODO: Just $ HList $ foldr BCons BNil $ const (Wildcard SType) <$> ts
151 xy = mangleNames ns 146 xy = mangleNames ns
152desugarMutual xs = error "desugarMutual" 147desugarMutual xs = error "desugarMutual"
153 148
154addFix n nt x
155 | usedS n x = SBuiltin FprimFix `SAppV` SLam Visible (maybe (Wildcard SType) id nt) (deBruijnify [n] x)
156
157{-
158addFix n x 149addFix n x
159 | usedS n x = SBuiltin FprimFix `SAppV` SLamV (deBruijnify [n] x) 150 | usedS n x = SBuiltin FprimFix `SAppV` SLamV (deBruijnify [n] x)
160-}
161 | otherwise = x 151 | otherwise = x
162 152
163mangleNames xs = SIName (foldMap sourceInfo xs) $ "_" ++ intercalate "_" (sName <$> xs) 153mangleNames xs = SIName (foldMap sourceInfo xs) $ "_" ++ intercalate "_" (sName <$> xs)