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

More clarity about convenience implementations #219

Merged
merged 2 commits into from
Jan 11, 2020
Merged

Conversation

travisbrown
Copy link
Contributor

@travisbrown travisbrown commented Jan 11, 2020

This is a pretty big change, but it fixes the last major problem with the public API that I think should be addressed before 1.0.

The change in #102 (first published in 0.12.0) adds RawFacade as a supertype of Facade that provides index parameters for Facade's methods. This was to maintain source compatibility, so that people working with Facade wouldn't have to change their implementations.

This naming doesn't seem ideal for the long term. Calling the "real" type class (i.e. the one used as a constraint) RawFacade and having Facade be essentially just a convenience class for implementers hurts discoverability and readability—"raw" just doesn't really mean anything in this context.

There aren't all that many implementations of RawFacade out in the world—a few in the support packages here, one in circe-jawn, and maybe several others. Updating this handful of implementations to use an explicit convenience trait seems like a small price to pay to gain some clarity in the API in 1.0, which (hopefully) will be around for a long time.

The change here renames the type class itself from RawFacade to Facade (and the context helper class from RawFContext to FContext), and moves all of the convenience implementation definitions (NoIndexFacade, SimpleFacade, MutableFacade, and NullFacade) into the Facade companion object.

It also removes the empty () parameter lists from jnull, jfalse, and jtrue, since unlike arrayContext(), etc., there's probably never a good reason for them to return mutable values.

I've also improved the API docs in a few places—e.g. where the Facade docs were just copy-pasted for the implementation traits, and I've added type annotations in some places where the inferred type would be more specific than it should be.

Copy link
Contributor

@larsrh larsrh left a comment

Choose a reason for hiding this comment

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

I don't have a clear enough idea of Jawn's internals in order to make an informed review of this, but the small amount of changes in the support modules and the tests suggests this is a conservative-enough change.

Copy link
Member

@rossabaker rossabaker left a comment

Choose a reason for hiding this comment

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

👍 I find this easier to understand. It is not too burdensome on library integrators, and I don't expect most downstream users to notice.

@travisbrown
Copy link
Contributor Author

Thanks all! I'll go ahead and publish a 1.0.0-RC3 that I think should be an actual candidate for release.

@travisbrown
Copy link
Contributor Author

Merged master to resolve conflict after #221.

@travisbrown travisbrown merged commit 1bcdff3 into master Jan 11, 2020
@larsrh larsrh deleted the topic/remove-raw branch January 27, 2020 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants