This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-13
Channels
- # beginners (17)
- # boot (16)
- # cider (13)
- # cljs-dev (26)
- # cljsrn (5)
- # clojure (155)
- # clojure-belgium (2)
- # clojure-spec (19)
- # clojure-uk (4)
- # clojurescript (32)
- # community-development (16)
- # core-async (12)
- # cursive (3)
- # datomic (7)
- # hoplon (14)
- # lambdaisland (1)
- # lumo (16)
- # microservices (1)
- # off-topic (3)
- # om (5)
- # onyx (4)
- # protorepl (1)
- # re-frame (1)
- # rum (1)
- # specter (6)
- # unrepl (32)
In https://clojure.org/about/spec#_minimize_intrusion it says "Don’t require that people e.g. define their functions differently."
Will there also be a way to provide a spec along with a function? e.g. (s/defn ...)
or (defn my-fn [args] {:args (s/cat ...)} ...
or something similar?
If I do want to define my functions with my spec?
@rmuslimov I think spec-tools has https://clojurians.slack.com/archives/C1B1BB2Q3/p1494558543543341 as data-specs: https://github.com/metosin/spec-tools/#data-specs
I think proactive data standardization work is better than passive data validation. Industrial assembly line recommended using standardized materials.
@danielcompton no, there will not be a way to combine function definition with spec
@misha What do you mean? like qeueu?
Don't believe so. If you mean query for type, you could use (instance? cljs.core/PersistentQueue #queue [])
You might be able to spec it with coll-of and some of the kind and into options, but I haven't tried
@alexmiller, what is a correct way to define spec for dynamic function (like reducing function)? I end up with following, is that legal?
(s/def ::reducing-fn
(s/fspec :args (s/cat ...))
What is dynamic about that?
AFAIR, s/fdef
accepts qualified fn symbol, with intention to use it on a function with that exact name.
There is an f(g)
where g
- is a function. I need to: 1) spec g
as an argument, 2) re-use that spec.
(s/def :foo (s/fspec ...))
seems to work, but I expect it to bite me in some way later.
That should work