Upon further investigation, there are helpful examples on this page
http://clojure.org/guides/spec, which was mentioned in the 1.9.0-alpha1
release notice, and there's a small example near the end of the Rationale
and Overview page. I still feel as if both pages kind of start in the
middle rat
Hi,
Is there a way to get a separate “repo” for specs to use with s/def? Use case:
I have optional modules that are enabled/disabled at startup time. An input
should only be valid if the plugin that defines that spec/behavior is included.
I guess maybe I could move this to compile time by excl
I’d advise everyone concerned/confused about the relationship between spec and
data representations to please spend some more time trying to understand spec
and, especially, dial back the rhetoric. I know what the Clojure philosophy is,
and it’s not some triviality.
specs are fundamentally code
On Wed, May 25, 2016 at 05:38:53PM -0700, Daniel wrote:
> I'd love to see a blog which shows an example app leveraging core.typed,
> clojure.spec, and core.contracts to gradually provide greater confidence in
> a codebase. Sort of a step-by-step.
Agreed, that'd be great. clojure.spec is documen
I'd love to see a blog which shows an example app leveraging core.typed,
clojure.spec, and core.contracts to gradually provide greater confidence in
a codebase. Sort of a step-by-step with best practices.
--
You received this message because you are subscribed to the Google
Groups "Clojure" gr
I'd love to see a blog which shows an example app leveraging core.typed,
clojure.spec, and core.contracts to gradually provide greater confidence in
a codebase. Sort of a step-by-step.
On Monday, May 23, 2016 at 9:12:29 AM UTC-5, Rich Hickey wrote:
>
> Introducing clojure.spec
>
> I'm happy to
The first predicate determines the generator.
> On May 25, 2016, at 8:03 PM, Leon Grapenthin wrote:
>
> Just had a chance to play around with spec. Looks like this is going to
> destroy a lot of problem space :) Thanks.
>
> Probably a bug:
> (s/exercise
> (s/and
> set?
>
Just had a chance to play around with spec. Looks like this is going to
destroy a lot of problem space :) Thanks.
Probably a bug:
(s/exercise
(s/and
set?
(s/coll-of
(s/with-gen keyword?
#(gen/elements [:s1 :s2 :s3]))
#{})))
;->
([#{}
Thanks Alex, perfect explanatory example
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first post.
To unsubsc
Really great work. I am curious about a couple of things though.
One is the choice of names like s/*, s/+ and s/?. Is there a specific
reason they were chosen? They aren't self-explanatory. It's not
automatically clear that because they are in the clojure.spec namespace
they resemble regex equi
I guess I'm confused why the Clojure philosophy of "data > fns > macros" is
being ignored in this particular case, when the other schema libraries show
that there is an army of end-users that want to do unexpected things with
specifications, and to do that, it would be easiest if they had data I
On Wednesday, May 25, 2016 at 4:46:57 PM UTC-4, kovasb wrote:
>
>
> On Wed, May 25, 2016 at 3:01 PM, Mike Rodriguez > wrote:
>>
>> I always really liked that Prismatic Schema had a "data representation"
>> and that seems to be the Clojure-way anyways. I haven't dug into this too
>> much yet, bu
To further clarify, you can and should turn on spec’s instrumentation *during
testing* (and interactive development) to get contract-system style
inter-function call checking. To the extent those tests are themselves
generative (e.g. spec’s) the coverage and ranges will be good.
As to whether a
In my mind, fspec is no different than fdef.
With fdef you specify what a function does. How do we know it works? -
generative testing. Wrappers only check individual calls.
Now you say your function returns a fn, and provides an fspec (same as fdef, a
trio of specs) for that. How do we know th
On Wed, May 25, 2016 at 3:01 PM, Mike Rodriguez wrote:
>
> I always really liked that Prismatic Schema had a "data representation"
> and that seems to be the Clojure-way anyways. I haven't dug into this too
> much yet, but I'm hoping that the Spec's do have some way to
> programmatically inspect
Rich,
Can you talk about the design process behind fspec?
What tradeoffs were in mind for fspec performing gen testing rather
than a traditional function contract wrapper a la racket/contract?
Thanks,
Ambrose
On Mon, May 23, 2016 at 5:20 PM, Rich Hickey wrote:
> I did most of the design of sp
I forgot to mention that if you run this with alpha2, this example won't
work due to a bug, but that is fixed in master for alpha3.
On Wednesday, May 25, 2016 at 2:38:07 PM UTC-5, Alex Miller wrote:
>
> s/or creates a spec and s/alt creates a regex op. Regex ops can be
> combined to describe a s
s/or creates a spec and s/alt creates a regex op. Regex ops can be combined
to describe a single sequence. Use s/alt if you are matching alternative
regex expressions in a sequential context - in particular where the
branches of the alt are themselves regex ops. Use s/or when matching a
single
>
>
>> Is there a recommended way to introspect specs for our own purposes
>>> (coercion, code generation)? An interpreter on the output of 'describe'
>>> might work (although it's a little complicated for fn specs), but I wanted
>>> to know if you all had any thoughts or plans for the future
I do actually have specs for spec and it would catch these. :) You can try
it yourself though:
(s/def ::s/req (s/* keyword?))
(s/def ::s/req-un (s/* keyword?))
(s/def ::s/opt (s/* keyword?))
(s/def ::s/opt-un (s/* keyword?))
(s/fdef s/keys
:args (s/cat :form ::s/any :env ::s/any;; form/en
On Wed, May 25, 2016 at 6:38 AM, Alex Miller wrote:
> So something like
>
> (defn valid-or-explain [spec data]
> (let [v (s/valid? spec data)]
> (when-not v (s/explain spec data))
> v))
>
>
Right, that's what I was originally thinking. The form Sean Corfield
suggested might make more s
It seems like the :req impls should go further to disallow trash input,
it's not immediately clear that they only allow namespaced keywords.
For example:
> (s/valid? (s/keys :req ["a"]) {:a 5})
true
> (s/valid? (s/keys :req [5]) {:a 5})
true
What ends up happening in practice, is (filter keyword?
What's the difference between clojure.spec/or and clojure.spec/alt? They
seem to accept the same inputs, multiple keyword-predicate pairs, and
output tagged values when used with clojure.spec/conform. Is
clojure.spec/or usable within a regular expression?
--
You received this message because y
I meant more that a failed pre-/post-condition throws AssertionError rather
than printing to the console and that a failure using clojure.spec should still
do the same thing.
The valid-or-explain function suggested would “work” in terms of being a
predicate but the AssertionError wouldn’t re
user=> (s/def ::a (s/or :r (s/cat :a ::a)
:k keyword?))
:user/a
user=> (binding [s/*recursion-limit* 2]
(map first (s/exercise ::a 10)))
(((:B)) :? (:+/K) (:Xc_D.__.+HC/JaCD) ((:*3)) :gJ1z.o.+?.lC0/!-ZDN9
:D.-?I.q8.z/-5* (:F67jy+2M.bB_.h62Cp+?._X?b6gv4.x+7.Gz_6.v9Tt15/*)
:!4J
lojure 1.9.0-alpha2 is now available.
Try it via
- Download: https://repo1.maven.org/maven2/org/clojure/clojure/1.9.0-alpha2
- Leiningen: [org.clojure/clojure "1.9.0-alpha2"]
1.9.0-alpha2 includes the following changes since 1.9.0-alpha1:
- Better describe for s/+
- Capture *recursion-limit* on
Approximate ETA for this, if known?
On Wednesday, 25 May 2016 09:08:29 UTC-7, Alex Miller wrote:
>
> Coming.
>
> On Wednesday, May 25, 2016 at 10:59:52 AM UTC-5, JvJ wrote:
>>
>> Any plans for cljs support?
>>
>
--
You received this message because you are subscribed to the Google
Groups "Clojur
I'm very happy about clojure.spec. I think. (!)
Two suggestions for the documentation page. Just my two cents.
First, it would be helpful to begin with a description of what clojure.spec
does and how it will be used, and one or two brief examples right at the
beginning--ideally before the fir
Coming.
On Wednesday, May 25, 2016 at 10:59:52 AM UTC-5, JvJ wrote:
>
> Any plans for cljs support?
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are m
Any plans for cljs support?
On Monday, 23 May 2016 07:12:29 UTC-7, Rich Hickey wrote:
>
> Introducing clojure.spec
>
> I'm happy to introduce today clojure.spec, a new core library and support
> for data and function specifications in Clojure.
>
> Better communication
>
> Clojure is a dynamic
Hopefully this will be made more clear in another guide about generators
and testing. As soon as we have time to write it. :)
On Wednesday, May 25, 2016 at 10:12:54 AM UTC-5, kovasb wrote:
>
>
> This seems like an important point, that didn't really come through (for
> me at least) in the docs s
On Wed, May 25, 2016 at 8:29 AM, Rich Hickey wrote:
> > Would you ever expect to use fdef/instrument active in production for
> validation
>
> No, definitely not. It’s that kind of runtime checking (and expense) that
> gives some dynamic lang checking systems a bad rep.
>
> The philosophy is - ge
On Wednesday, May 25, 2016 at 5:30:03 AM UTC-7, Rich Hickey wrote:
>
> The philosophy is - generative testing has made sure your function
> complies with the specs. So, testing the :ret and :fn properties over and
> over is redundant and serves no point.
>
> OTOH, you may encounter user- or exte
In practice this is a lot of information though, and often it's a
coincidence that
the dispatch entry comes first since maps are unordered.
See the following error I found in practice using namespaced keywords
pervasively
missing a :spec-play.destruct/type|or method. It's rather large and
I'm glad
Rich pointed out that this is telling you the predicate
:my.domain/event-type and the value it received: {:event/type
:event/restart} which seems to be telling you everything you need to know
wrt to the missing method.
The dispatch method is opaque (even though it is simple here), so doesn't
As mentioned in the guide, while conformers can be used to implement
coercions, that is something you should think about very carefully. When
you register a spec with a conformer, you are making a choice for all
possible future consumers of that spec as to how they are getting the
conformed dat
You can get the registry with (s/registry), which is just a map of spec
names (namespaced keywords) to the spec. Is that what you're looking for?
If you have registered (s/def ::foo string?)
then you can find the spec with (::foo (s/registry))
On Wednesday, May 25, 2016 at 7:37:07 AM UTC-5, Gar
We do not plan to create or support a backport lib for Clojure 1.8. Mostly
just a matter of choosing not to spend our time on maintaining multiple
code bases.
On Wednesday, May 25, 2016 at 8:34:41 AM UTC-5, Gary Trakhman wrote:
>
> It would be helpful to make clojure.spec available as a lib for
We will be adding CLJ-1910 and CLJ-1919 for namespaced map literals and
namespaced map destructuring in an alpha relatively soon.
Nothing else to announce re 1.9 right now.
On Wednesday, May 25, 2016 at 1:52:33 AM UTC-5, Tatu Tarvainen wrote:
>
>
> Are there plans for what will be the release c
So something like
(defn valid-or-explain [spec data]
(let [v (s/valid? spec data)]
(when-not v (s/explain spec data))
v))
I'll mention it to Rich, not sure though.
On Tuesday, May 24, 2016 at 10:56:03 PM UTC-5, puzzler wrote:
>
> One thing that has always limited the value of pre and
It would be helpful to make clojure.spec available as a lib for 1.8. I
have opted to backport clojure.spec (a 30-second copy/paste job) into our
application running on 1.8 for an easy transition, and maybe others would
be more comfortable bringing in a lib until 1.9 is further along. That
would a
Probably - can you file a jira for that?
On Tuesday, May 24, 2016 at 10:53:43 PM UTC-5, Ambrose Bonnaire-Sergeant
wrote:
>
> Thanks for the guide Alex.
>
> Is it possible to get more information in the "no method" error returned by
> multi-spec?
>
> (s/explain :event/event {:event/type :event/res
On Tuesday, May 24, 2016 at 7:26:57 PM UTC-5, Leif wrote:
>
> Hi, Alex, thanks for the responsiveness.
>
> The paths refer to tags in the schemas, not keys in the map. However, this
>> has been asked about several times today and Rich has added support for a
>> :in clause that will track the ke
On Tuesday, May 24, 2016 at 5:45:47 PM UTC-5, Sean Corfield wrote:
>
> We have 1.9.0 Alpha 1 in QA at World Singles and plan to start using
> clojure.spec this week. We’ve gone to production on Alpha builds ever since
> 1.3 and almost never had any problems (in five years – time has flown
> pas
I answered my own question in the specific case, this seems to work:
(defn to-int
[x]
(try
(Long/parseLong x)
(catch Exception _
nil)))
(s/def ::intable (s/conformer to-int))
(s/conform (s/cat :ints ::intable) ["5"])
> {:ints 5}
On Wed, May 25, 2016 at 8:36 AM Gary Trakhman
Is there a public way to get the registry's spec at a keyword? I can
envision other libs being built around the spec registry, and I'm trying to
write a small one (coercions) to see if I can use spec for this use-case.
Is that non-sanctioned kind of thing going forward?
The likely candidate seems
> Would you ever expect to use fdef/instrument active in production for
> validation
No, definitely not. It’s that kind of runtime checking (and expense) that gives
some dynamic lang checking systems a bad rep.
The philosophy is - generative testing has made sure your function complies
with th
Once you are talking about some cross-key predicate you wish to satisfy you are
talking about another property of the map itself. So, you can use composition
to provide further constraints on the map:
(s/and (s/keys …) cross-cutting-pred)
keys is not going to be the place for that kind of cross
Speaking of recursive definitions: how to provide an override in a
recursive spec?
Would it be possible to have path suffixes (in addition to paths not in
replacement of) in the override map?
Thanks,
Christophe
On Mon, May 23, 2016 at 6:16 PM, Alex Miller wrote:
> Yes, you can create recursive
Would it be a reasonable feature request to ask for Java classes to be
implicitly converted to specs, the same as predicates? FWIW,
plumatic/schema allows classes to be used as schemas.
The spec guide contains this example:
(import java.util.Date) (s/valid? #(instance? Date %) (Date.)) ;; true
Congratulations on the alpha release!
I'm also curious what the plans are for 1.9 beyond clojure.spec (which
looks awesome btw).
R.
On 25 May 2016 at 07:52, Tatu Tarvainen wrote:
>
> Are there plans for what will be the release content of 1.9?
> I didn't see anything in the Clojure jira.
>
> Pa
51 matches
Mail list logo