Skip to content
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

Free invariant HTTP codecs #6917

Draft
wants to merge 2 commits into
base: series/0.23
Choose a base branch
from
Draft

Conversation

rossabaker
Copy link
Member

Replaces the renderer and parser of the core HTTP types with a free algebra. This can then be interpreted into:

  • Cats Parse for nice error and composition in String contexts
  • A prospective binary parser that gets right to ByteBuffer
  • Renderer for compatibility with today
  • A prospective fast encoder that goes straight to ByteBuffer
  • Similar for Netty's ByteBuf, if that backend wants to make its own codecs instead of intermediate passes through Netty's

A path away from #6915. A different take on #5356.

@mergify mergify bot added series/0.23 PRs targeting 0.23.x module:core labels Jan 12, 2023
@rossabaker
Copy link
Member Author

Going to be blocked on typelevel/cats#2620. The FreeInvariantMonoidal works for product types, but we need an invariant betwixt Alternative and Decidable to model sum types.

Early performance returns are good. Renderer is a bit slower, but still fast. Cats Parse is actually slightly (but consistently!) faster than before!

@codecov-commenter

This comment was marked as off-topic.

@rossabaker
Copy link
Member Author

rossabaker commented Jan 12, 2023

Mastodon conversation reminds me of prior art for JSON in xenomorph: https://github.com/nuttycom/xenomorph

writer << c
}

implicit val catsContravariantMonoidalForHttp4sUtilRenderable: ContravariantMonoidal[Renderer] =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny nitpick: somewhere in http4s, we use implicit lazy vals. Shouldn't we apply it here also?

@SystemFw
Copy link
Member

In terms of api expressiveness, you might also want to look at https://systemfw.org/dynosaur/#/schema
the library was originally inspired by xenomorph as well, but it ended up making different tradeoffs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:core series/0.23 PRs targeting 0.23.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants