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

Configurable sum of product styling #35

Merged
merged 13 commits into from
Dec 2, 2021
Merged

Conversation

chiroptical
Copy link
Collaborator

@chiroptical chiroptical commented Nov 15, 2021

This is a much less intrusive version of #33. Introduce a configuration option to handle the various encoding styles of Aeson (see https://hackage.haskell.org/package/aeson-2.0.1.0/docs/Data-Aeson-TH.html#t:SumEncoding). We are using a non-existent style that was suggested in this PR.

Spawns a few issues:

@chiroptical chiroptical changed the title Add option and failing test Configurable enum styling Nov 15, 2021
Comment on lines +1 to +14
@JsonClassDiscriminator("tag")
@Parcelize
@Serializable
sealed class Enum : Parcelable {
@Parcelize
@Serializable
@SerialName("dataCons0")
data class DataCons0(val contents: Record0) : Enum()

@Parcelize
@Serializable
@SerialName("dataCons1")
data class DataCons1(val contents: Record1) : Enum()
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@tadfisher Yeah?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah yeah yeah!

Copy link
Collaborator Author

@chiroptical chiroptical left a comment

Choose a reason for hiding this comment

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

Avoid adding annotations for a user.

src/Moat/Pretty/Kotlin.hs Outdated Show resolved Hide resolved
src/Moat/Pretty/Kotlin.hs Outdated Show resolved Hide resolved
@chiroptical chiroptical changed the title Configurable enum styling Configurable sum of product styling Nov 16, 2021
@@ -44,6 +44,9 @@ module Moat
-- ** Option type and defaults
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The changes here are just passing options down to enumExp

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@parsonsmatt parsonsmatt left a comment

Choose a reason for hiding this comment

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

overall looks good, though a refactor to ReaderT might be nice for keeping the option passing cleaner.

@@ -860,16 +864,17 @@ mkTypeAlias typName instTys = \case
-- | Make a void type (empty enum)
mkVoid ::
() =>
Options ->
Copy link
Collaborator

Choose a reason for hiding this comment

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

Feels like a good use of ReaderT Options - maybe put that in with MoatM?

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah lol i see that you already have this as a refactoring potential!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is definitely getting tedious to pass these around over and over.

@parsonsmatt parsonsmatt merged commit 9f1f470 into master Dec 2, 2021
@parsonsmatt parsonsmatt deleted the tagged-object-option branch December 2, 2021 17:11
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