From 3672361157e385a897b1f066d8e3b6ce39e2307e Mon Sep 17 00:00:00 2001 From: Fabian Date: Mon, 29 Mar 2021 14:06:10 +0200 Subject: [PATCH] refactor SML to be more portable --- impls/sml/main.sml | 2 +- impls/sml/step0_repl.sml | 2 ++ impls/sml/step1_read_print.sml | 2 ++ impls/sml/step2_eval.sml | 2 ++ impls/sml/step3_env.sml | 8 ++++---- impls/sml/step4_if_fn_do.sml | 8 ++++---- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/impls/sml/main.sml b/impls/sml/main.sml index 3fef5bda..ccd9b5d0 100644 --- a/impls/sml/main.sml +++ b/impls/sml/main.sml @@ -1 +1 @@ -val _ = repl () +val _ = main () diff --git a/impls/sml/step0_repl.sml b/impls/sml/step0_repl.sml index 15ae0c3c..82406e83 100644 --- a/impls/sml/step0_repl.sml +++ b/impls/sml/step0_repl.sml @@ -21,3 +21,5 @@ fun repl () = ) | NONE => () ) end + +fun main () = repl () diff --git a/impls/sml/step1_read_print.sml b/impls/sml/step1_read_print.sml index f9bb1510..7c5174f2 100644 --- a/impls/sml/step1_read_print.sml +++ b/impls/sml/step1_read_print.sml @@ -23,3 +23,5 @@ fun repl () = ) | NONE => () ) end + +fun main () = repl () diff --git a/impls/sml/step2_eval.sml b/impls/sml/step2_eval.sml index 93972570..f60639e3 100644 --- a/impls/sml/step2_eval.sml +++ b/impls/sml/step2_eval.sml @@ -66,3 +66,5 @@ fun repl () = ) | NONE => () ) end + +fun main () = repl () diff --git a/impls/sml/step3_env.sml b/impls/sml/step3_env.sml index 70d97311..d98c9a3b 100644 --- a/impls/sml/step3_env.sml +++ b/impls/sml/step3_env.sml @@ -62,9 +62,7 @@ val initEnv = ENV [] |> bind [ | _ => raise NotApplicable "'/' requires arguments") ] -fun repl () = repl' initEnv - -and repl' e = +fun repl e = let open TextIO in ( print("user> "); @@ -73,7 +71,9 @@ and repl' e = let val (e', s) = rep e line val _ = print(s ^ "\n") in - repl' e' + repl e' end | NONE => () ) end + +fun main () = repl initEnv diff --git a/impls/sml/step4_if_fn_do.sml b/impls/sml/step4_if_fn_do.sml index 5dea13cc..a8bb8bef 100644 --- a/impls/sml/step4_if_fn_do.sml +++ b/impls/sml/step4_if_fn_do.sml @@ -51,9 +51,7 @@ fun rep e s = val initEnv = ENV [] |> bind coreNs -fun repl () = repl' initEnv - -and repl' e = +fun repl e = let open TextIO in ( print("user> "); @@ -62,7 +60,9 @@ and repl' e = let val (e', s) = rep e line val _ = print(s ^ "\n") in - repl' e' + repl e' end | NONE => () ) end + +fun main () = repl initEnv