From 5b3a0fe4224856158c96bdcc38c02913f275011e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20R=C3=A4tzel?= Date: Thu, 20 Jul 2023 20:43:12 +0000 Subject: [PATCH] Clean up for readability and consistency Notice we can reuse `emitReferenceExpression` to implement `emitClosureArgument`. This change not only removes redundant parts but also enables reusing the entries in `environmentFunctions` --- .../src/ElmInteractive.elm | 26 ++++--------------- implement/elm-time/Program.cs | 2 +- implement/elm-time/elm-time.csproj | 4 +-- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/implement/elm-time/ElmTime/compile-elm-program/src/ElmInteractive.elm b/implement/elm-time/ElmTime/compile-elm-program/src/ElmInteractive.elm index 9b958e94..e15037bb 100644 --- a/implement/elm-time/ElmTime/compile-elm-program/src/ElmInteractive.elm +++ b/implement/elm-time/ElmTime/compile-elm-program/src/ElmInteractive.elm @@ -2482,26 +2482,10 @@ emitExpressionInDeclarationBlockLessClosureArgument stackBeforeAddingDeps origin emitClosureArgument : EmitStack -> { closureCaptures : List String } -> Result String Pine.Expression emitClosureArgument stack { closureCaptures } = - let - emitForName name = - case Dict.get name stack.environmentDeconstructions of - Nothing -> - Err - ("Failed to find declaration for closure capture '" - ++ name - ++ "'. There are " - ++ String.fromInt (Dict.size stack.environmentDeconstructions) - ++ " environment deconstructions in scope: " - ++ String.join ", " (Dict.keys stack.environmentDeconstructions) - ) - - Just _ -> - Ok (ReferenceExpression name) - in closureCaptures - |> List.map emitForName + |> List.map (emitReferenceExpression >> (|>) stack) |> Result.Extra.combine - |> Result.andThen (ListExpression >> emitExpression stack) + |> Result.map Pine.ListExpression type alias ClosureFunctionEntry = @@ -3302,15 +3286,15 @@ emitReferenceExpression name compilation = case Dict.get name compilation.environmentDeconstructions of Nothing -> Err - ("Failed getting deconstruction for '" + ("Failed referencing '" ++ name ++ "'. " ++ String.fromInt (Dict.size compilation.environmentDeconstructions) - ++ " deconstructions on the current stack: " + ++ " deconstructions in scope: " ++ String.join ", " (Dict.keys compilation.environmentDeconstructions) ++ ". " ++ String.fromInt (List.length compilation.environmentFunctions) - ++ " functions on the current stack: " + ++ " functions in scope: " ++ String.join ", " (List.map .functionName compilation.environmentFunctions) ) diff --git a/implement/elm-time/Program.cs b/implement/elm-time/Program.cs index 0fe77b8e..9e7feb81 100644 --- a/implement/elm-time/Program.cs +++ b/implement/elm-time/Program.cs @@ -17,7 +17,7 @@ namespace ElmTime; public class Program { - public static string AppVersionId => "2023-07-18"; + public static string AppVersionId => "2023-07-19"; private static int AdminInterfaceDefaultPort => 4000; diff --git a/implement/elm-time/elm-time.csproj b/implement/elm-time/elm-time.csproj index bf929197..7a0fe61a 100644 --- a/implement/elm-time/elm-time.csproj +++ b/implement/elm-time/elm-time.csproj @@ -5,8 +5,8 @@ net7.0 ElmTime elm-time - 2023.0718.0.0 - 2023.0718.0.0 + 2023.0719.0.0 + 2023.0719.0.0 enable true