-
Notifications
You must be signed in to change notification settings - Fork 70
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
adt trait for sealed hierarchies with common members #787
Conversation
@@ -10,7 +10,7 @@ import smithy4s.schema.Schema.int | |||
object OrderNumber extends Newtype[Int] { | |||
val id: ShapeId = ShapeId("smithy4s.example", "OrderNumber") | |||
val hints: Hints = Hints( | |||
smithy.api.Default(smithy4s.Document.fromDouble(0.0d)), | |||
smithy.api.Box(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wut ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is from changing the smithy file in sampleSpecs over to use the smithy version 2 syntax directly. Prior it was a version 1 file being loaded which would have added these other traits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the "box" trait had been removed :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modules/codegen/src/smithy4s/codegen/internals/SmithyToIR.scala
Outdated
Show resolved
Hide resolved
Let me know if there are other example usages that you think would be helpful to add. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, for me, the only missing piece for this PR is a bit of documentation to complement what we have for @adtMember
in ADTs section of the docs
Added some documentation. As an aside, should we now deprecate the |
Additionally, there are some requirements that are added onto the structure shapes that the union targets: | ||
|
||
1. The structures must NOT be the target of any other union, structure, etc. They can only be the target in the ONE union that is annotated with the `adt` trait. | ||
2. The structures must contain at least one member. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that one is necessary, but happy to merge the PR as is and revise later
Adds a new trait
smithy4s.meta#adt
that when applied to Union shapes will lead to different rendering. Namely, the rendering will take common mixins from members of the ADT and move them to the level of the sealed trait. More documentation and test case examples to come as the PR progresses.TODO: