diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-05-05 13:44:51 +0200 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-05-05 13:44:51 +0200 |
commit | f15331d0746b538c2a83547776d266b5834a60e3 (patch) | |
tree | 5ec396ab0f940ce4b82b61f09f0b40c7616e30fd /src/LambdaCube/Compiler/InferMonad.hs | |
parent | ccbf10decb3f467ea07b41e2369791aed6955e7a (diff) |
simplify local function handling
Diffstat (limited to 'src/LambdaCube/Compiler/InferMonad.hs')
-rw-r--r-- | src/LambdaCube/Compiler/InferMonad.hs | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/src/LambdaCube/Compiler/InferMonad.hs b/src/LambdaCube/Compiler/InferMonad.hs index e96a619d..a86518c8 100644 --- a/src/LambdaCube/Compiler/InferMonad.hs +++ b/src/LambdaCube/Compiler/InferMonad.hs | |||
@@ -26,6 +26,7 @@ import Control.Monad.Writer | |||
26 | import Control.Arrow hiding ((<+>)) | 26 | import Control.Arrow hiding ((<+>)) |
27 | import Control.DeepSeq | 27 | import Control.DeepSeq |
28 | 28 | ||
29 | import LambdaCube.Compiler.Utils | ||
29 | import LambdaCube.Compiler.DeBruijn | 30 | import LambdaCube.Compiler.DeBruijn |
30 | import LambdaCube.Compiler.Pretty hiding (braces, parens) | 31 | import LambdaCube.Compiler.Pretty hiding (braces, parens) |
31 | import LambdaCube.Compiler.DesugaredSource hiding (getList) | 32 | import LambdaCube.Compiler.DesugaredSource hiding (getList) |
@@ -160,18 +161,6 @@ downTo n m = map Var [n+m-1, n+m-2..n] | |||
160 | 161 | ||
161 | withEnv e = local $ second (<> e) | 162 | withEnv e = local $ second (<> e) |
162 | 163 | ||
163 | mkELet n x xt = {-(if null vs then id else trace_ $ "mkELet " ++ show (length vs) ++ " " ++ show n)-} term | ||
164 | where | ||
165 | vs = [Var i | i <- Set.toList $ free x <> free xt] | ||
166 | nloc = length vs | ||
167 | fn = FunName (mkFName n) nloc (ExpDef x) xt | ||
168 | |||
169 | term = mkFun fn vs [] $ getFix x 0 | ||
170 | |||
171 | getFix (Lam z) i = Lam $ getFix z (i+1) | ||
172 | getFix (TFun FprimFix _ [t, Lam f]) i = subst 0 (foldl app_ term (downTo 0 i)) f | ||
173 | getFix x _ = x | ||
174 | |||
175 | lamPi h t (ET x y) = ET (Lam x) (Pi h t y) | 164 | lamPi h t (ET x y) = ET (Lam x) (Pi h t y) |
176 | 165 | ||
177 | -- Ambiguous: (Int ~ F a) => Int | 166 | -- Ambiguous: (Int ~ F a) => Int |