More clarity about convenience implementations #219
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ofFacade
that provides index parameters forFacade
's methods. This was to maintain source compatibility, so that people working withFacade
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 havingFacade
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
toFacade
(and the context helper class fromRawFContext
toFContext
), and moves all of the convenience implementation definitions (NoIndexFacade
,SimpleFacade
,MutableFacade
, andNullFacade
) into theFacade
companion object.It also removes the empty
()
parameter lists fromjnull
,jfalse
, andjtrue
, since unlikearrayContext()
, 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.