From a7401f0ee3e9b465cf985fc0ad8f0fb1f87451b5 Mon Sep 17 00:00:00 2001 From: Rakarake Date: Tue, 28 Mar 2023 15:55:06 +0200 Subject: [PATCH] Monomorphizer main fix --- src/Monomorphizer/Monomorphizer.hs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Monomorphizer/Monomorphizer.hs b/src/Monomorphizer/Monomorphizer.hs index 17994c0..49b3871 100644 --- a/src/Monomorphizer/Monomorphizer.hs +++ b/src/Monomorphizer/Monomorphizer.hs @@ -183,11 +183,14 @@ morphExp expectedType exp = case exp of -- Creates a new identifier for a function with an assigned type newName :: M.Type -> T.Bind -> Ident -newName t (T.Bind (Ident bindName, _) _ _) = Ident (bindName ++ "$" ++ newName' t) - where - newName' :: M.Type -> String - newName' (M.TLit (Ident str)) = str - newName' (M.TFun t1 t2) = newName' t1 ++ "_" ++ newName' t2 +newName t (T.Bind (Ident bindName, _) _ _) = + if bindName == "main" then + Ident bindName + else Ident (bindName ++ "$" ++ newName' t) + where + newName' :: M.Type -> String + newName' (M.TLit (Ident str)) = str + newName' (M.TFun t1 t2) = newName' t1 ++ "_" ++ newName' t2 -- Monomorphization step monomorphize :: T.Program -> M.Program