-
Notifications
You must be signed in to change notification settings - Fork 68
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
Replace schematic implementation by schema visitor #296
Conversation
): DocumentEncoder[Map[K, V]] = { | ||
val keyEncoder = apply(key) | ||
val valueEncoder = apply(value) | ||
fromNotKey[Map[K, V]] { map => |
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.
the fromNotKey
should disappear. Instead, we should have another SchemaVisitor
that would compute a Option[KeyEncoder[A]]
(and same on the Decoder
side), the interface of which would be something like :
trait KeyEncoder[A] {
def apply(a) : String
}
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.
Do you mind if I do these updates in a subsequent PR? There are a few things that could be re-written. I saw some of them but I told myself: let's do the mechanical translation first (remove all instances of schematic) and then we'll improve the visitors.
it will reduce the review overhead. you can consider this PR as a one-to-one translation (mostly, because some signature are different and so some code has to change)
modules/core/src/smithy4s/http/internals/StringAndBlobCodecSchemaVisitor.scala
Outdated
Show resolved
Hide resolved
Add documentation regarding unions and their encodings
Last push removes Schematic altogether, but it's based on #295 so I'll make this as Draft until the other one is merged back in here |
... to make it easier to write memoised dispatching logic The `union` method in SchemaVisitor is an obvious footgun, because it makes it a hard to memoise the compilation of schemas for each alternative. This PR revises the `union` method to expose a new construct `Alt.Dispatcher`, which does the heavylifting of memoizing the result of compiling schemas, and dispatching the union instance to the correct alternative. * Creates a `Alt.Dispatcher` construct that aims at streamlining the implementation of the `union` methods in SchemaVisitors, which is the hardest due to the fact that the implementor has to think about memoization. * Creates an `EncoderK` typeclass (used by Alt.Dispatcher) to generalise over what is an encoder, and streamline further the implementation of union encoders. * Examplifies the use of `Alt.Dispatcher` in DocumentEncoderSchemaVisitor This should remove the need for #260
No description provided.