This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-06
Channels
- # admin-announcements (1)
- # alda (2)
- # beginners (5)
- # boot (59)
- # clara (6)
- # cljs-dev (40)
- # cljsrn (32)
- # clojure (28)
- # clojure-austin (1)
- # clojure-belgium (67)
- # clojure-greece (60)
- # clojure-ireland (1)
- # clojure-japan (1)
- # clojure-russia (55)
- # clojure-spain (14)
- # clojure-spec (39)
- # clojure-uk (26)
- # clojurescript (152)
- # clojurewerkz (1)
- # cursive (21)
- # datomic (3)
- # dirac (15)
- # emacs (7)
- # events (2)
- # funcool (4)
- # hoplon (43)
- # immutant (1)
- # lambdaisland (1)
- # lein-figwheel (6)
- # leiningen (1)
- # off-topic (1)
- # om (23)
- # onyx (67)
- # other-languages (6)
- # pedestal (7)
- # planck (13)
- # proton (3)
- # protorepl (2)
- # re-frame (6)
- # reagent (5)
- # ring-swagger (6)
- # spacemacs (1)
- # specter (2)
- # yada (27)
Curious if there has been any thought given to adding a doc string parameter to clojure.spec/def
like there is in clojure.core/def
? I understand the spec should be self-explanatory, but it's nice to be able to capture additional information/description about the spec. I've found myself adding comments that would be nice to have as doc strings that could then also be parsed programatically.
yes, there has been thought about it
not sure if anyone noticed, but you can now call doc with a registered spec keyword to get it's spec definition. that's a place that docstring could show up.
but it's something Rich is still thinking about afaik
Hello all! I learn clojurescript. Today I discovered that clojurescript doesn't throw Exceptions in code above like Clojure. Can clojure.spec help in such situations? I use reagent and want prevent state updating from using inappropriate function.
@mike1452: Hey Mike, welcome to ClojureScript! clojure.spec can definitely help you here:
@nwjsmith: Thank you!!
nwjsmith: the spec needs to be (s/cat :arg integer?)' instead of just
integer?`, right?
s/integer/number/
That's what I thought at first, but maybe this is a situation where a pred is implicitly converted to a spec?
I guess I'll just go try it :)
when passed to valid?
or conform
, predicates will be implicitly converted to a spec, which I think is what happens here.
it throws an error when you call it with a number as well
it's not about spec vs predicate it's about spec-for-a-single-arg vs spec-for-an-arglist
@mike1452 looks like the example I gave above is wrong. The call to s/fdef
should be:
(s/fdef inc :args (s/cat :x number?))
thanks @gfredericks@nwjsmith: got it! Thanks!
Is there a nice way to spec the following?
"I want a map of arbitrary keywords whose values must conform to some predicate"
@nwjsmith: Beauty, thank you 🙂
with clojure.spec I'm finding myself wanting to use some kind long namespaces for my keywords, they are just getting to be a borden to write, for example (s/keys :req [:my-app.some-ns.clock/at, :my-app.some-ns.clock/namespace])
, the namespace my-app.some-ns.clock
doesn't actually exists, it's just helpful to avoid name clashing, I'm writing those in the my-app.some-ns
I was thinking that would be useful to be able to alias those namespaces so they can be used in a simpler way, for example:
it's possible to alias like this with the currently clojure features?
I believe if you require a namespace like (ns my-ns (:require [my-app.some-ns.clock :as clock]))
you can use ::clock/foo
and it will resolve to :my-app.some-ns.clock
.
@noonian: yes, but that would require me to create a file with that namespace, that's what I would like to avoid
@wilkerlucio: see this proposed feature http://dev.clojure.org/jira/browse/CLJ-1910
thanks @jr, I had saw that one, and I agree that will help, but only on map cases... when you are setting it as keywords for lists (on the s/keys
for example) you can't use that, so we would still have to repeat the typing, I believe aliasing is a more general solution here that could be very useful with long namespaces
user=> (create-ns 'my-app.some-ns.clock)
#object[clojure.lang.Namespace 0x3b7d3a38 "my-app.some-ns.clock"]
user=> (alias 'clock 'my-app.some-ns.clock)
nil
user=> ::clock/foo
:my-app.some-ns.clock/foo
user=>
@hiredman: thanks, I'm going to try that soon, do you think that can work on cljs as well?
yeah, I have to fix some compilation issues here and then I'll try it out