diff --git a/src/Main.elm b/src/Main.elm index d5d92f6..2551e1f 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -4,7 +4,7 @@ import Html.Events exposing (onInput) import Browser exposing (element) import Canvas exposing (Shape) import Dict exposing (Dict) -import Parser exposing (Parser, Problem(..), DeadEnd, (|.), (|=), variable, succeed, symbol, int, spaces, map, oneOf, lazy, sequence, Trailing(..), keyword, run, backtrackable) +import Parser exposing (Parser, Problem(..), DeadEnd, (|.), (|=), variable, succeed, symbol, int, spaces, map, oneOf, lazy, sequence, Trailing(..), keyword, run, backtrackable, end) import Color import Canvas exposing (Point, path, lineTo, circle, shapes, stroke, lineWidth, fill, rect) import Set @@ -357,9 +357,9 @@ init fs = view : Model -> Html Msg view m = let + parseResult = Result.mapError humanParseError (run (parseProg |. end) m.programText) evalResult = Result.map (\(_, s) -> s) - <| Result.andThen (\prg -> evaluateAll prg initialState) - <| Result.mapError humanParseError (run parseProg m.programText) + <| Result.andThen (\prg -> evaluateAll prg initialState) parseResult toRender = Result.withDefault initialState evalResult error = case evalResult of Err e -> [ p [ classList [ ("centered", True), ("error", True), ("shadow", True) ] ] [ text e ] ]