From e70eae776a274dffb4bb2269a682267f13185ae1 Mon Sep 17 00:00:00 2001 From: Rakarake Date: Tue, 2 May 2023 17:25:22 +0200 Subject: [PATCH] =?UTF-8?q?Maybe=20made=20lets=20work=20in=20monomorphizer?= =?UTF-8?q?=20=F0=9F=99=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Monomorphizer/Monomorphizer.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Monomorphizer/Monomorphizer.hs b/src/Monomorphizer/Monomorphizer.hs index 62aa601..5a0783e 100644 --- a/src/Monomorphizer/Monomorphizer.hs +++ b/src/Monomorphizer/Monomorphizer.hs @@ -253,7 +253,18 @@ morphExp expectedType exp = case exp of -- New bind to process newBindName <- morphBind expectedType bind' return $ M.EVar (coerce newBindName) - T.ELet (T.Bind{}) _ -> error "lets not possible yet" + T.ELet (T.Bind (identB, tB) args (expB, tExpB)) (exp, tExp) -> + if length args > 0 then error "only constants in lets allowed" + else do + tB' <- getMonoFromPoly tB + tExpB' <- getMonoFromPoly tExpB + tExp' <- getMonoFromPoly tExp + expB' <- morphExp tExpB' expB + exp' <- morphExp tExp' exp + return $ M.ELet (M.Bind (identB, tB') [] (expB', tExpB')) (exp', tExp') + +-- ELet (Bind' t) (ExpT' t) +-- Bind (Id' t) [Id' t] (ExpT' t) -- | Monomorphizes case-of branches. morphBranch :: T.Branch -> EnvM (Maybe M.Branch)