Closed bergmark closed 8 years ago
This looks great, I think it's the best we can do without a complete dictionary rewrite. It's sad the RawJsonAndXml
stuff can't reuse the individual parts, but until we fix #20 I don't think we can easily improve this.
Sweet.
I'll add the newtypes so the signatures become something like Either Json Xml
and (Json, Xml)
and I'll merge once I have tested it properly.
Sounds good!
I'm reconsidering the (Json, Xml)
type for output. The ByteStrings are lazy which is good, but in my use case i currently need to do one http request for each result so it's wasteful. Perhaps it should be changed to callback style Either Json Xml -> m ByteString
to avoid this.
Yeah, that sounds like a more efficient format, good idea.
A first stab at allowing I/O of raw json bytestrings.
The first commit adds
rawJsonI/O
that behaves likerawXmlI/O
, they cannot be combined with other dictionaries.The second commit adds the
RawJsonAndXmlI/O
combinations. Ideally it would suffice to sayrawXmlO . rawJsonO
but since both take aByteString
handlers using this needs to return a tuple so the driver can choose which to send. Similarily withrawJsonAndXmlI
; here we need to acceptByteString
s in two different formats which translates to the handler getting anEither
as input.It seems like solving this in a more proper way would be a lot of work of unknown complexity since this is orthogonal from how other dictionaries combine. Is this ok as an initial version?
Another undecided point is whether to use
Either ByteString ByteString
and(ByteString, ByteString)
. I'm leaning towards newtyping both to make it a bit less error-prone to pick the right bytestring.