From: sforman Date: Sat, 29 Jul 2023 14:19:08 +0000 (-0700) Subject: I don't think andThen helps here? X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=dc065d1943eb04fd039317eb9e4dad71910bfbf9;p=joypy%2FThun.git I don't think andThen helps here? --- 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