-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Use named specs instead of predicates #76
Comments
bhb
added a commit
to bhb/speculative
that referenced
this issue
Nov 3, 2018
bhb
added a commit
to bhb/speculative
that referenced
this issue
Nov 3, 2018
slipset
pushed a commit
that referenced
this issue
Nov 4, 2018
borkdude
pushed a commit
that referenced
this issue
Nov 4, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently speculative uses predicates like
ifn?
andseqable?
in the specs. This produces correct specs (and is an idiomatic use of spec). However, I think using named specs instead of predicates is a better approach for speculative, since it is a set of specs shared across the community.I suggest that all predicates should be wrapped in a spec. For instance, instead of using
ifn?
, we could defineand then use
::ifn
everywhere.Benefits
Most importantly for my purposes, it's easy to store additional information about named specs in separate registries. For instance, expound can add human-readable error messages. This isn't easy to do with predicates (due to differences in how CLJ and CLJS resolve symbols) and it's also pretty invasive: while it's reasonable for a user to register a custom error message for
:speculative.core/ifn
, it's not clear that it's a good idea to register one forifn?
, which would affect ALL specs, not just ones defined in speculative. Note that the proposal to add metadata to specs also involves associating keyword names with metadata, so if that proposal is adopted, this change will continue to enable users to register metadata.It's easy to attach a common generator to a spec. See
::map-entry
as an example.If end users use
check
, they can use the:gen
option (a "map from spec names to generator overrides") to provide generators for named specs.Downsides
::ifn
instead ofifn?
)The text was updated successfully, but these errors were encountered: