@@ -9,6 +9,7 @@ data LVar = Loc Int | Glob Name
99data LExp = LV LVar
1010 | LApp Bool Name [LExp] -- True = tail call
1111 | LLazyApp Name [LExp] -- True = tail call
12+ | LLazyExp LExp
1213 | LLet Name LExp LExp -- name just for pretty printing
1314 | LLam [Name] LExp -- lambda, lifted out before compiling
1415 | LCon Int Name [LExp]
@@ -81,6 +82,11 @@ lift env (LApp tc n args) = do args' <- mapM (lift env) args
8182 return (LApp tc n args')
8283lift env (LLazyApp n args) = do args' <- mapM (lift env) args
8384 return (LLazyApp n args')
85+lift env (LLazyExp (LConst c)) = return (LConst c)
86+lift env (LLazyExp e) = do e' <- lift env e
87+ fn <- getNextName
88+ addFn fn (LFun fn env e')
89+ return (LLazyApp fn (map (LV . Glob) env))
8490lift env (LLet n v e) = do v' <- lift env v
8591 e' <- lift (env ++ [n]) e
8692 return (LLet n v' e')