-
Notifications
You must be signed in to change notification settings - Fork 31
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
Make it easier to compose ConcreteCodecs #104
Comments
I think a good solution should be to duplicate all those functions for both modules / types. This means in your example you should be able to do directly Maybe we should come up with a better / shorter alias for |
Yes I think renaming If so then how about naming it |
No, actually they are both very generic, the main difference being that |
Hmm ok, I think my confusion came about when working with them and trying to convert between concrete and pair of functions using Also when I was trying to write |
Yes, we need to provide codecs like I'll think what's the best way to accomplish this. |
Currently
jreqWith
etc require that the codec passed to them is a "pair of functions" type codec. Such as(JsonValue -> a' ParseResult) * (a' -> JsonValue)
. However, when defining codecs for more complex types it's preferable to use the applicative style which creates aConcreteCodec
. It's then cumbersome to use this codec in another codec as it requires converting back to "pair of functions" type by doingcodec |> Codec.ofConcrete |> Codec.compose jsonObjToValueCodec
.As an example consider the following types:
Then you might want to define codecs for them in another module which currently requires writing them like this:
So it would be nicer if we could avoid having to convert between the two codec representations.
The text was updated successfully, but these errors were encountered: