Skip to content

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()
} No newline at end of file
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.

@chiroptical chiroptical changed the title Configurable enum styling Configurable sum of product styling Nov 16, 2021

-- * Options for encoding types

-- ** 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.

-- | 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