Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First draft of elm encoder backend #9

Merged
merged 5 commits into from
Mar 11, 2020
Merged

First draft of elm encoder backend #9

merged 5 commits into from
Mar 11, 2020

Conversation

reesh-a
Copy link
Contributor

@reesh-a reesh-a commented Mar 10, 2020

WIP

Copy link
Member

@AttilaMihaly AttilaMihaly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's address those minor issues I commented and then I'll approve.

Comment on lines +16 to +17
typeDefToEncoder : extra -> Name -> AccessControlled (Definition extra) -> Declaration
typeDefToEncoder e typeName typeDef =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you just want to ignore the extra type argument you can remove the first argument. Type variables in function signatures are defined the first time they are used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I could have removed it but I decided to keep it just in case I need to put something in the Node range a of my output.


functionName : String
functionName =
toCamelCase <| [ "encode" ] ++ typeName
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's stylistic but I would do [ "encode" ] ++ typeName |> Name.toCamelCase. I also like to prefix functions that are not defined in this module. Makes things easier to follow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I noticed the same while I was reading the PR.

Comment on lines +7 to +8
const packageDefWorker = require('./Morphir.Elm.CLI').Elm.Morphir.Elm.CLI.init()
const elmEncoderWorker = require('./Morphir.Elm.EncodersCLI').Elm.Morphir.Elm.EncodersCLI.init()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Longer term I think we should just have one worker and use it as a facade to consolidate all the functionality but I'm guessing this was meant to be a temporary solution anyway so OK for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good suggestion. I did think of that but like you said, for the purposes of getting something out quicker I fell short of consolidating it.

@@ -4,7 +4,7 @@
"description": "Elm bindings for Morphir",
"scripts": {
"test": "elm-test",
"make-cli": "cd cli && elm make src/Morphir/Elm/CLI.elm --output Morphir.Elm.CLI.js --optimize"
"make-cli": "cd cli && elm make src/Morphir/Elm/CLI.elm --output Morphir.Elm.CLI.js --optimize && elm make src/Morphir/Elm/EncodersCLI.elm --output Morphir.Elm.EncodersCLI.js --optimize"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use a better build tool such as Gulp. Created issue for it: #10

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no experience with JS build tools. Would be fun to know what's out there since I have always been intrigued by the choices available in the JS ecosystem.

case tpe of
Reference fqName typeArgs _ ->
case fqName of
FQName _ _ [ "int" ] ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the kind of stuff that we should put into the SDK as a reusable pattern. It would be too much to do now but can you please add a TODO comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean these should be parsed as data-structures represented in the SDK, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, it should be added as a pattern in the SDL. This would be SDK.intPattern. But this is longer term.


functionName : String
functionName =
[ "encode" ] ++ typeName |> toCamelCase
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do Name.toCamelCase as discussed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my bad!

Copy link
Member

@AttilaMihaly AttilaMihaly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still needs a bit of work.

Copy link
Member

@AttilaMihaly AttilaMihaly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@reesh-a reesh-a merged commit 77bd8cc into finos:master Mar 11, 2020
AttilaMihaly pushed a commit that referenced this pull request Nov 5, 2020
Added Scala Library dependency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants