Skip to content

Commit

Permalink
Merge pull request #11 from reesh-a/master
Browse files Browse the repository at this point in the history
Fixed maybe encoders and other minor errors
  • Loading branch information
reesh-a authored Mar 11, 2020
2 parents 77bd8cc + bcb0111 commit 582b6da
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/Morphir/Elm/Backend/Codec/Gen.elm
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ typeToEncoder fwdNames varName tpe =
let
caseValExpr : Node Expression
caseValExpr =
FunctionOrValue [] "arg"
varName
|> varPathToExpr
|> emptyRangeNode

justPattern : Pattern
Expand Down Expand Up @@ -200,14 +201,17 @@ typeToEncoder fwdNames varName tpe =
in
elmJsonEncoderApplication
(elmJsonEncoderFunction "object")
(TupledExpression
[ emptyRangeNode <| Literal <| Path.toString Name.toCamelCase "." varName
, emptyRangeNode <|
elmJsonEncoderApplication
(ListExpr <|
[ TupledExpression
[ Path.toString Name.toCamelCase "." varName |> Literal |> emptyRangeNode
, elmJsonEncoderApplication
(elmJsonEncoderFunction "object")
(ListExpr
(fields |> List.map fieldEncoder |> List.map emptyRangeNode)
)
|> emptyRangeNode
]
|> emptyRangeNode
]
)

Expand All @@ -219,7 +223,7 @@ typeToEncoder fwdNames varName tpe =

varPathToExpr : List Name -> Expression
varPathToExpr names =
FunctionOrValue [] <| Path.toString Name.toCamelCase "." names
Path.toString Name.toCamelCase "." names |> FunctionOrValue []


elmJsonEncoderApplication : Expression -> Expression -> Expression
Expand Down Expand Up @@ -274,10 +278,10 @@ customTypeTopExpr expr =
elmJsonEncoderApplication
(elmJsonEncoderFunction "object")
(ListExpr
[ emptyRangeNode <|
TupledExpression
[ Literal "$type" |> emptyRangeNode
, expr |> emptyRangeNode
]
[ TupledExpression
[ Literal "$type" |> emptyRangeNode
, expr |> emptyRangeNode
]
|> emptyRangeNode
]
)

0 comments on commit 582b6da

Please sign in to comment.