-
Notifications
You must be signed in to change notification settings - Fork 3
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
Duplicate definition in Codec for shared types #3
Comments
This is the complete generated Codec.elm ...
|
Could you give me the full Scala code you're using? With the |
Even better: add a PR with a test case in https://github.com/reactormonk/scala-elm-types/blob/master/test/src/test/scala/elmtype/CompileTest.scala - to run that locally, you'll need the |
Thank you for the prompt response. Here is a complete scala example that exposes the problem:
On running, in System.out you can see that the type alias for Ball (and it's decoder/encoder) is generated twice. ElmTypeMain.main emits a chunk of elm for each individual type and as both ClientToServer and ServerToClient reference Ball it gets generated twice. So I guess possible solutions might be: I did try to make a test case, but didn't get massively far because CompileTest.compileExternal is currently geared around testing one type at time, so might need a bit of work. |
Ok, that would explain why I didn't test for that case. Sounds like |
Considering it again, you should be able to use |
ah ha, yes that does indeed work, very elegant :) it's a bit messy having the one extra unused type, encoder and decoder but thats probably preferable to adding a lot of complexity to the code/tests thank you |
I'll still think about a better way to do it, but the quickfix should last you that long. |
Hi,
I've been using scala-elm-types for a while and it's been working very nicey, it's awesome not having to handcode encoders and decoders :)
However, I've hit a snag when case classes share the same type, for example:
The Ball type (and its encoder/decoder) are generated twice (see errors below)
Is there anyway to prevent this?
Many thanks,
Paulos
The text was updated successfully, but these errors were encountered: