summaryrefslogtreecommitdiff
path: root/src/LambdaCube/Compiler/InferMonad.hs
diff options
context:
space:
mode:
authorPéter Diviánszky <divipp@gmail.com>2016-05-05 13:44:51 +0200
committerPéter Diviánszky <divipp@gmail.com>2016-05-05 13:44:51 +0200
commitf15331d0746b538c2a83547776d266b5834a60e3 (patch)
tree5ec396ab0f940ce4b82b61f09f0b40c7616e30fd /src/LambdaCube/Compiler/InferMonad.hs
parentccbf10decb3f467ea07b41e2369791aed6955e7a (diff)
simplify local function handling
Diffstat (limited to 'src/LambdaCube/Compiler/InferMonad.hs')
-rw-r--r--src/LambdaCube/Compiler/InferMonad.hs13
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
26import Control.Arrow hiding ((<+>)) 26import Control.Arrow hiding ((<+>))
27import Control.DeepSeq 27import Control.DeepSeq
28 28
29import LambdaCube.Compiler.Utils
29import LambdaCube.Compiler.DeBruijn 30import LambdaCube.Compiler.DeBruijn
30import LambdaCube.Compiler.Pretty hiding (braces, parens) 31import LambdaCube.Compiler.Pretty hiding (braces, parens)
31import LambdaCube.Compiler.DesugaredSource hiding (getList) 32import LambdaCube.Compiler.DesugaredSource hiding (getList)
@@ -160,18 +161,6 @@ downTo n m = map Var [n+m-1, n+m-2..n]
160 161
161withEnv e = local $ second (<> e) 162withEnv e = local $ second (<> e)
162 163
163mkELet 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
175lamPi h t (ET x y) = ET (Lam x) (Pi h t y) 164lamPi 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