CLJ2116: Support for selective conforming with clojure.spec#1
Open
ikitommi wants to merge 3 commits intoclojure:masterfrom
Open
CLJ2116: Support for selective conforming with clojure.spec#1ikitommi wants to merge 3 commits intoclojure:masterfrom
ikitommi wants to merge 3 commits intoclojure:masterfrom
Conversation
* pass 3rd argument (cc, conforming-callback) via - conform*, explain* - conform, explain-data, explain, explain-str - needed internal functions
conform has extra 4-arity version with boolean specize? to allow bypassing the (potentially slow) specize.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 DUMMY PR for discussion purposes, will create a patch via Jira is gets further.
What
Support separation of
conformfrom Specs, allowing different conforming to be run for same specs at runtime.This is already implemented in spec-tools, but it needs to use Dynamic Binding and wrap specs into Spec Records to make this work.
Why
Allows Specs to be used as a runtime transformation engine, main use cases being the Web: sending and receiving Spec'd data over different formats (String, JSON, Transit) without needing to write manually differently conforming specs for all combinations.
How
cc(conforming callback) to:conform*,explain*,conform,explain,explain-dataandexplain-str: all support the old arities, causingccto be set tonilconform*andexplain*always have the extra parameter, passed on to internal spec functionsccis set inconform, it is called with aspecargument. It should return eithernil(default case, run conform as before) or a anonymousconform*function, which is used to pre-conform the value before passing it to normal conformconform*fromconform* need to be called via top-levelconform` - which has a perf optimized arity for this.Todo
explainNotes
The actual supporting converters (string->long, string->keyword) and
Conforming Callbackcould be hosted in non-core project like in spec-tools to enable moving fast - and supporting both clj & cljs.Example