Skip to content

Commit

Permalink
Run programs with mlton successfully
Browse files Browse the repository at this point in the history
  • Loading branch information
UberPyro committed Sep 27, 2023
1 parent df15686 commit 1fb6cf8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion gibbon-compiler/src/Gibbon/Compiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
4 changes: 3 additions & 1 deletion gibbon-compiler/src/Gibbon/L1/GenSML.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1fb6cf8

Please sign in to comment.