Skip to content

Commit

Permalink
Change extra arg position and naming. finos#46, finos#25
Browse files Browse the repository at this point in the history
  • Loading branch information
AttilaMihaly committed Mar 31, 2020
1 parent e984520 commit 8c336bf
Show file tree
Hide file tree
Showing 4 changed files with 468 additions and 487 deletions.
24 changes: 12 additions & 12 deletions src/Morphir/Elm/Frontend.elm
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ mapFunctionImplementation sourceFile argumentNodes expression =
mapExpression sourceFile body

(Node range firstParam) :: restOfParams ->
Result.map2 (\lambdaArg lambdaBody -> Value.Lambda lambdaArg lambdaBody (sourceLocation range))
Result.map2 (\lambdaArg lambdaBody -> Value.Lambda (sourceLocation range) lambdaArg lambdaBody)
(mapPattern sourceFile (Node range firstParam))
(lambdaWithParams restOfParams body)
in
Expand Down Expand Up @@ -698,7 +698,7 @@ mapExpression sourceFile (Node range exp) =
toApply restOfValuesReversed
|> Result.map
(\funValue ->
Value.Apply funValue lastValue sourceLocation
Value.Apply sourceLocation funValue lastValue
)
in
expNodes
Expand All @@ -710,42 +710,42 @@ mapExpression sourceFile (Node range exp) =
Expression.FunctionOrValue moduleName valueName ->
case ( moduleName, valueName ) of
( [], "True" ) ->
Ok (Value.Literal (Value.BoolLiteral True) sourceLocation)
Ok (Value.Literal sourceLocation (Value.BoolLiteral True))

( [], "False" ) ->
Ok (Value.Literal (Value.BoolLiteral False) sourceLocation)
Ok (Value.Literal sourceLocation (Value.BoolLiteral False))

_ ->
Ok (Value.Reference (fQName [] (moduleName |> List.map Name.fromString) (valueName |> Name.fromString)) sourceLocation)
Ok (Value.Reference sourceLocation (fQName [] (moduleName |> List.map Name.fromString) (valueName |> Name.fromString)))

Expression.Integer value ->
Ok (Value.Literal (Value.IntLiteral value) sourceLocation)
Ok (Value.Literal sourceLocation (Value.IntLiteral value))

Expression.Hex value ->
Ok (Value.Literal (Value.IntLiteral value) sourceLocation)
Ok (Value.Literal sourceLocation (Value.IntLiteral value))

Expression.Negation arg ->
mapExpression sourceFile arg
|> Result.map (Number.negate sourceLocation sourceLocation)

Expression.Floatable value ->
Ok (Value.Literal (Value.FloatLiteral value) sourceLocation)
Ok (Value.Literal sourceLocation (Value.FloatLiteral value))

Expression.Literal value ->
Ok (Value.Literal (Value.StringLiteral value) sourceLocation)
Ok (Value.Literal sourceLocation (Value.StringLiteral value))

Expression.CharLiteral value ->
Ok (Value.Literal (Value.CharLiteral value) sourceLocation)
Ok (Value.Literal sourceLocation (Value.CharLiteral value))

Expression.TupledExpression expNodes ->
expNodes
|> List.map (mapExpression sourceFile)
|> ResultList.toResult
|> Result.mapError List.concat
|> Result.map (\elems -> Value.Tuple elems sourceLocation)
|> Result.map (Value.Tuple sourceLocation)

other ->
Ok (Value.Literal (Value.StringLiteral (Debug.toString other)) sourceLocation)
Ok (Value.Literal sourceLocation (Value.StringLiteral (Debug.toString other)))



Expand Down
2 changes: 1 addition & 1 deletion src/Morphir/IR/SDK/Number.elm
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ numberClass extra =

negate : extra -> extra -> Value extra -> Value extra
negate refExtra valueExtra arg =
Value.Apply (Value.Reference (fromLocalName "negate") refExtra) arg valueExtra
Value.Apply valueExtra (Value.Reference refExtra (fromLocalName "negate")) arg
Loading

0 comments on commit 8c336bf

Please sign in to comment.