Skip to content

Commit

Permalink
Rename Application to FunctionCall
Browse files Browse the repository at this point in the history
  • Loading branch information
jfmengels committed Aug 17, 2023
1 parent 0d3a421 commit cab4987
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/Elm/Parser/Expression.elm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ expression =
succeed
(Node
(Range.combine (Node.range first :: List.map Node.range rest))
(Application first (List.reverse rest))
(FunctionCall first (List.reverse rest))
)

promoter : List (Node Expression) -> Parser State (Node Expression)
Expand Down
8 changes: 4 additions & 4 deletions src/Elm/Processing.elm
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ fixExprs exps =
x

head_ :: rest ->
Expression.Application head_ rest
Expression.FunctionCall head_ rest

[] ->
-- This case should never happen
Expand Down Expand Up @@ -359,7 +359,7 @@ visitExpression : Node Expression -> Node Expression
visitExpression expression =
visitExpressionInner <|
case expression of
Node r (Expression.Application function args) ->
Node r (Expression.FunctionCall function args) ->
Node r (fixApplication (function :: args))

_ ->
Expand All @@ -370,8 +370,8 @@ visitExpressionInner : Node Expression -> Node Expression
visitExpressionInner (Node range expression) =
Node range <|
case expression of
Expression.Application function args ->
Expression.Application (visitExpression function) (List.map visitExpression args)
Expression.FunctionCall function args ->
Expression.FunctionCall (visitExpression function) (List.map visitExpression args)

Expression.Operation op dir left right ->
Expression.Operation op
Expand Down
6 changes: 3 additions & 3 deletions src/Elm/Syntax/Expression.elm
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ type Expression
| ListLiteral (List (Node Expression))
| FunctionOrValue ModuleName String
| PrefixOperator String
| Application (Node Expression) (List (Node Expression))
| FunctionCall (Node Expression) (List (Node Expression))
| Operation String InfixDirection (Node Expression) (Node Expression)
| If (Node Expression) (Node Expression) (Node Expression)
| TupleExpression (List (Node Expression))
Expand Down Expand Up @@ -249,7 +249,7 @@ isOperatorApplication e =
encode : Expression -> Value
encode expr =
case expr of
Application head l ->
FunctionCall head l ->
encodeTyped "application" (JE.list (Node.encode encode) (head :: l))

Operation op dir left right ->
Expand Down Expand Up @@ -461,7 +461,7 @@ decoder =
(\() ->
decodeTyped
[ ( "application"
, decodeNonemptyList decodeNested |> JD.map (\( head, rest ) -> Application head rest)
, decodeNonemptyList decodeNested |> JD.map (\( head, rest ) -> FunctionCall head rest)
)
, ( "operatorapplication", decodeOperatorApplication )
, ( "functionOrValue", JD.map2 FunctionOrValue (JD.field "moduleName" ModuleName.decoder) (JD.field "name" JD.string) )
Expand Down
2 changes: 1 addition & 1 deletion src/Elm/Writer.elm
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ writeExpression (Node range inner) =
f diffLines (List.map Tuple.second l)
in
case inner of
Expression.Application head xs ->
Expression.FunctionCall head xs ->
case xs of
[] ->
writeExpression head
Expand Down
4 changes: 2 additions & 2 deletions tests/Elm/Parser/CaseExpressionTests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ all =
, firstCase =
( Node empty <| NamedPattern (QualifiedNameRef [] "Increment") []
, Node empty <|
Application
FunctionCall
(Node empty <| FunctionOrValue [] "model")
[ Node empty <| Operator "+"
, Node empty <| IntegerLiteral 1
Expand All @@ -205,7 +205,7 @@ all =
, restOfCases =
[ ( Node empty <| NamedPattern (QualifiedNameRef [] "Decrement") []
, Node empty <|
Application
FunctionCall
(Node empty <| FunctionOrValue [] "model")
[ Node empty <| Operator "-"
, Node empty <| IntegerLiteral 1
Expand Down
4 changes: 2 additions & 2 deletions tests/Elm/Parser/CombineTestUtil.elm
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ noRangeRecordSetter ( a, b ) =
noRangeInnerExpression : Expression -> Expression
noRangeInnerExpression inner =
case inner of
Expression.Application head xs ->
Expression.Application (noRangeExpression head) (List.map noRangeExpression xs)
Expression.FunctionCall head xs ->
Expression.FunctionCall (noRangeExpression head) (List.map noRangeExpression xs)

Expression.Operation op dir left right ->
Expression.Operation op dir (noRangeExpression left) (noRangeExpression right)
Expand Down
20 changes: 10 additions & 10 deletions tests/Elm/Parser/DeclarationsTests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ all =
, arguments = [ Node { start = { row = 1, column = 5 }, end = { row = 1, column = 6 } } (VarPattern_ "x") ]
, expression =
Node { start = { row = 1, column = 9 }, end = { row = 1, column = 14 } }
(Application
(FunctionCall
(Node { start = { row = 1, column = 9 }, end = { row = 1, column = 10 } } (FunctionOrValue [] "x"))
[ Node { start = { row = 1, column = 11 }, end = { row = 1, column = 12 } } (Operator "+")
, Node { start = { row = 1, column = 13 }, end = { row = 1, column = 14 } } (IntegerLiteral 1)
Expand Down Expand Up @@ -229,7 +229,7 @@ all =
{ arguments = []
, expression =
Node { start = { row = 2, column = 3 }, end = { row = 2, column = 62 } }
(Application
(FunctionCall
(Node { start = { row = 2, column = 3 }, end = { row = 2, column = 18 } } (FunctionOrValue [] "beginnerProgram"))
[ Node { start = { row = 2, column = 19 }, end = { row = 2, column = 62 } }
(Expression.Record
Expand Down Expand Up @@ -275,7 +275,7 @@ all =
{ firstCase =
( Node { start = { row = 3, column = 5 }, end = { row = 3, column = 14 } } (NamedPattern { moduleName = [], name = "Increment" } [])
, Node { start = { row = 4, column = 7 }, end = { row = 4, column = 16 } }
(Application
(FunctionCall
(Node { start = { row = 4, column = 7 }, end = { row = 4, column = 12 } } (FunctionOrValue [] "model"))
[ Node { start = { row = 4, column = 13 }, end = { row = 4, column = 14 } } (Operator "+")
, Node { start = { row = 4, column = 15 }, end = { row = 4, column = 16 } } (IntegerLiteral 1)
Expand All @@ -285,7 +285,7 @@ all =
, restOfCases =
[ ( Node { start = { row = 6, column = 5 }, end = { row = 6, column = 14 } } (NamedPattern { moduleName = [], name = "Decrement" } [])
, Node { start = { row = 7, column = 7 }, end = { row = 7, column = 16 } }
(Application
(FunctionCall
(Node { start = { row = 7, column = 7 }, end = { row = 7, column = 12 } } (FunctionOrValue [] "model"))
[ Node { start = { row = 7, column = 13 }, end = { row = 7, column = 15 } } (Operator "-")
, Node { start = { row = 7, column = 15 }, end = { row = 7, column = 16 } } (IntegerLiteral 1)
Expand Down Expand Up @@ -384,7 +384,7 @@ all =
{ arguments = []
, expression =
Node { start = { row = 2, column = 3 }, end = { row = 2, column = 23 } }
(Application
(FunctionCall
(Node { start = { row = 2, column = 3 }, end = { row = 2, column = 7 } } (FunctionOrValue [] "text"))
[ Node { start = { row = 2, column = 8 }, end = { row = 2, column = 23 } } (StringLiteral SingleQuote "Hello, World!")
]
Expand All @@ -408,7 +408,7 @@ all =
{ arguments = []
, expression =
Node { start = { row = 2, column = 3 }, end = { row = 2, column = 23 } }
(Application
(FunctionCall
(Node { start = { row = 2, column = 3 }, end = { row = 2, column = 7 } } (FunctionOrValue [] "text"))
[ Node { start = { row = 2, column = 8 }, end = { row = 2, column = 23 } } (StringLiteral SingleQuote "Hello, World!")
]
Expand Down Expand Up @@ -450,13 +450,13 @@ all =
{ arguments = [ Node { start = { row = 1, column = 13 }, end = { row = 1, column = 19 } } (VarPattern_ "update"), Node { start = { row = 1, column = 20 }, end = { row = 1, column = 28 } } (VarPattern_ "sendPort") ]
, expression =
Node { start = { row = 1, column = 31 }, end = { row = 1, column = 83 } }
(Application
(FunctionCall
(Node { start = { row = 1, column = 31 }, end = { row = 1, column = 36 } } (FunctionOrValue [] "curry"))
[ Node { start = { row = 1, column = 37 }, end = { row = 1, column = 39 } } (Operator "<|")
, Node { start = { row = 1, column = 40 }, end = { row = 1, column = 56 } }
(TupleExpression
[ Node { start = { row = 1, column = 41 }, end = { row = 1, column = 55 } }
(Application
(FunctionCall
(Node { start = { row = 1, column = 41 }, end = { row = 1, column = 48 } } (FunctionOrValue [] "uncurry"))
[ Node { start = { row = 1, column = 49 }, end = { row = 1, column = 55 } } (FunctionOrValue [] "update")
]
Expand Down Expand Up @@ -495,7 +495,7 @@ all =
( Node { start = { row = 3, column = 5 }, end = { row = 3, column = 14 } }
(NamedPattern { moduleName = [], name = "Increment" } [])
, Node { start = { row = 4, column = 7 }, end = { row = 4, column = 16 } }
(Application
(FunctionCall
(Node { start = { row = 4, column = 7 }, end = { row = 4, column = 12 } } (FunctionOrValue [] "model"))
[ Node { start = { row = 4, column = 13 }, end = { row = 4, column = 14 } } (Operator "+")
, Node { start = { row = 4, column = 15 }, end = { row = 4, column = 16 } } (IntegerLiteral 1)
Expand All @@ -506,7 +506,7 @@ all =
[ ( Node { start = { row = 6, column = 5 }, end = { row = 6, column = 14 } }
(NamedPattern { moduleName = [], name = "Decrement" } [])
, Node { start = { row = 7, column = 7 }, end = { row = 7, column = 16 } }
(Application
(FunctionCall
(Node { start = { row = 7, column = 7 }, end = { row = 7, column = 12 } } (FunctionOrValue [] "model"))
[ Node { start = { row = 7, column = 13 }, end = { row = 7, column = 15 } } (Operator "-")
, Node { start = { row = 7, column = 15 }, end = { row = 7, column = 16 } } (IntegerLiteral 1)
Expand Down
Loading

0 comments on commit cab4987

Please sign in to comment.