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 JsonDecoder Algebra #2907
Add JsonDecoder Algebra #2907
Conversation
@@ -115,6 +115,12 @@ trait CirceInstances extends JawnInstances { | |||
Uri.fromString(str).leftMap(_ => "Uri") | |||
} | |||
|
|||
implicit class JsonDecoderSyntax[F[_]: JsonDecoder](private val req: Message[F])( | |||
implicit F: JsonDecoder[F]) { |
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.
Isn't it already specified as F
context bound?
(also - don't you want to move this constraint to methods to avoid JsonDecoderSyntax
allocation with extends AnyVal
trick?)
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.
Whoops. Yes. I switched how I was invoking it and left the old one. will fix these two.
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.
Can't extend AnyVal because of our position -
value class may not be a member of another class
- We could move these syntax's out but it would be a lot more involved move that I think I would rather do separately from this concept.
@@ -115,6 +115,11 @@ trait CirceInstances extends JawnInstances { | |||
Uri.fromString(str).leftMap(_ => "Uri") | |||
} | |||
|
|||
implicit class JsonDecoderSyntax[F[_]](private val req: Message[F])(implicit F: JsonDecoder[F]) { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
@@ -115,6 +115,11 @@ trait CirceInstances extends JawnInstances { | |||
Uri.fromString(str).leftMap(_ => "Uri") | |||
} | |||
|
|||
implicit class JsonDecoderSyntax[F[_]](private val req: Message[F])(implicit F: JsonDecoder[F]) { |
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.
It's a little weird we've ended up with syntax in our instances, but that's not a new problem. Something to ruminate over, though.
object JsonDecoder { | ||
def apply[F[_]](implicit ev: JsonDecoder[F]): JsonDecoder[F] = ev | ||
|
||
implicit def impl[F[_]: Sync]: JsonDecoder[F] = new JsonDecoder[F] { |
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.
Thinking about what other implementations could plausibly exist. I guess for the other Stream.Compiler
s, though you'd want a MonadError
for Id
and Pure
. It's not a typeclass with laws, so I guess a constant decoder "works".
I get the aversion to Sync
, but I need some help thinking about why it's good to pretend that this can't fail.
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.
A little worried about having two ways to do something, and offering no guidance to users which to pick. An example would be helpful. And this has made me pause and think about which implementations we might create based on other Stream.Compiler
s. But I think this is reasonable.
I think this isn't being used in the client, do you folks think we could get that in 1.0.0? Happy to help, just wondering if there are any arguments against |
I've never used it, so I can't say how well it has aged. But symmetry seems good. If it has worked out well for people, I'd be 👍. |
Single Type Abstraction for separation of Sync and the locations using the
Json
, which is primarily businesss logic where we'd prefer to remove effects.