From dc065d1943eb04fd039317eb9e4dad71910bfbf9 Mon Sep 17 00:00:00 2001 From: sforman Date: Sat, 29 Jul 2023 07:19:08 -0700 Subject: [PATCH] I don't think andThen helps here? --- implementations/Elm/src/Joy.elm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/implementations/Elm/src/Joy.elm b/implementations/Elm/src/Joy.elm index 8779dd2..331bfe2 100644 --- a/implementations/Elm/src/Joy.elm +++ b/implementations/Elm/src/Joy.elm @@ -1,6 +1,7 @@ module Joy exposing (doit) import String exposing (replace, words) +import Result exposing (andThen) type JoyType @@ -39,13 +40,12 @@ joy_eval symbol stack expression = joy_add : (List JoyType) -> (List JoyType) -> Result String (List JoyType, List JoyType) joy_add stack expression = case pop_int(stack) of - Err msg -> Err msg Ok (a, s0) -> case pop_int(s0) of - Err msg -> Err msg Ok (b, s1) -> - let c = a + b in - Ok ((push_int c s1), expression) + Ok ((push_int ((+) a b) s1), expression) + Err msg -> Err msg + Err msg -> Err msg push_int : Int -> (List JoyType) -> (List JoyType) @@ -63,6 +63,11 @@ pop_int stack = _ -> Err "Not an integer." + + + + + -- Printer joyTermToString : JoyType -> String -- 2.11.0