From 1fb6cf8e62108fed5984bc363994921ef76280bf Mon Sep 17 00:00:00 2001 From: UberPyro Date: Wed, 27 Sep 2023 06:05:09 +0000 Subject: [PATCH] Run programs with mlton successfully --- gibbon-compiler/src/Gibbon/Compiler.hs | 6 +++++- gibbon-compiler/src/Gibbon/L1/GenSML.hs | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gibbon-compiler/src/Gibbon/Compiler.hs b/gibbon-compiler/src/Gibbon/Compiler.hs index f2cdf0e37..522b36c60 100644 --- a/gibbon-compiler/src/Gibbon/Compiler.hs +++ b/gibbon-compiler/src/Gibbon/Compiler.hs @@ -585,10 +585,14 @@ compileMPL fp = do runMPL :: FilePath -> IO () runMPL fp = do - cd <- system $ "./" <> dropExtension fp + cd <- system $ prefix <> dropExtension fp case cd of ExitFailure n -> error $ "SML executable failed with code " <> show n ExitSuccess -> pure () + where + prefix = case takeDirectory fp of + "" -> "./" + _ -> "" goSML :: Config -> L1.Prog1 -> (FilePath -> IO a2) -> StateT b IO L1.Prog1 goSML config prog acts = diff --git a/gibbon-compiler/src/Gibbon/L1/GenSML.hs b/gibbon-compiler/src/Gibbon/L1/GenSML.hs index 393137f68..516e9a368 100644 --- a/gibbon-compiler/src/Gibbon/L1/GenSML.hs +++ b/gibbon-compiler/src/Gibbon/L1/GenSML.hs @@ -317,7 +317,9 @@ reduceFunDefs keyword funDef doc = ppMainExpr :: Maybe (Exp1, b) -> Doc ppMainExpr opt = case opt of Nothing -> mempty - Just (exp0, _) -> "val _ = " <> ppE exp0 <> semi + Just (exp0, _) -> + "val _ = " <> ppE exp0 <> semi + <> "\nval _ = print \"\\n\"" ppDDefs :: DDefs1 -> Doc ppDDefs ddefs = case elems ddefs of