Skip to content

Swift: Ensure all enum case labels are lowercased - #100

Merged
tadfisher merged 13 commits into
masterfrom
tad/swift-lowercase-enum
Jun 11, 2026
Merged

tadfisher merged 13 commits into
masterfrom
tad/swift-lowercase-enum

Conversation

@tadfisher

Copy link
Copy Markdown
Collaborator

Currently, the Swift backend emits enum cases verbatim to match the constructor name in Haskell. It's a fairly strong idiom for these to be lowercased, so when Moat is configured to preserve the Haskell name (via constructorLowerFirst = False), it is possible for Moat to generate undesirable code.

There's a bunch of housekeeping in the first two commits; I can separate these if needed.

@tadfisher
tadfisher requested review from josephsumabat and kylebshr and removed request for josephsumabat June 10, 2026 21:21
@tadfisher
tadfisher force-pushed the tad/swift-lowercase-enum branch from 2326e76 to b6d1d92 Compare June 10, 2026 22:08
Will not build as HLS doesn't support it
Always conform to a raw value type and Codable, otherwise the
JSON representation doesn't make sense.
@tadfisher
tadfisher force-pushed the tad/swift-lowercase-enum branch from 74a708a to 0886d27 Compare June 11, 2026 00:33
var container = encoder.container(keyedBy: CodingKeys.self)
switch (self) {
case let .dataCons0:
case let .dataCons0(enumField0, enumField1):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How come we did not have enumField0, enumField1 before, but in the encode and decode functions they were used? I think this is right I am just curious how it worked before this fix :-)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It didn't work, this was pulled from #96 to fix sums using TaggedFlatEncodingStyle.

@tadfisher
tadfisher merged commit d069055 into master Jun 11, 2026
17 checks passed
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