-
Notifications
You must be signed in to change notification settings - Fork 76
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
Add xml-support [decoder only] #489
Conversation
Add a number of construct that allow for the parsing of XML data into Smithy4s-generated datatypes. The heavy-lifting (parsing) is provided by fs2-data. We interop with it by implementing the `DocumentBuilder` typeclass to create instances of an XmlDocument ADT we control.
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.
will take a closer look tomorrow
.compile | ||
.last | ||
.flatMap(_.liftTo[IO](new Throwable("BOOM"))) | ||
.map(XmlCursor.fromDocument) |
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.
thoughts on adding a decoder.readDocument
that hides this?
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.
Dude the PR is still very much a draft, so keep your guns holstered (I'm merely raising it in case in case I get kicked in the head by a horse, so that the code doesn't die with me), but yeah that's where I was heading towards 😄
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.
my brother in Christ, you asked for the review
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.
my brother in Christ, you asked for the review
Nah I said "if you want to have fun", implying that XML is a lot of fun
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.
look at you cheeky bastard 😂
schema.compile(this).emap(refinement.asFunction) | ||
|
||
def lazily[A](suspend: Lazy[Schema[A]]): XmlDecoder[A] = new XmlDecoder[A] { | ||
lazy val underlying: XmlDecoder[A] = suspend.map(compile(_)).value |
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.
perhaps we can avoid the double lazy (Eval has one built in) and move the .value
to inside `read?
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.
Actually I had tried to remove the double lazy in the json decoder, and it was actually slightly more performant to keep way it was. I was quite surprised by it. I may be wrong, but I think it's because it's may actually hitting to lazy vals on the hotpath.
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.
interesting
hints: Hints, | ||
alternatives: Vector[SchemaAlt[U, _]], | ||
dispatch: Alt.Dispatcher[Schema, U] | ||
): XmlDecoder[U] = ??? |
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.
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.
even so CI wouldn't complain about them I think, because it's not deadcode.
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.
fair nuff
Add a number of construct that allow for the parsing of XML data into Smithy4s-generated datatypes. The heavy-lifting (parsing) is provided by fs2-data. We interop with it by implementing the
DocumentBuilder
typeclass to create instances of an XmlDocument ADT we control.NB :