Fork me on GitHub

In 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?


I think proactive data standardization work is better than passive data validation. Industrial assembly line recommended using standardized materials.


Standardize input and output data at the beginning and end of data processing


Proactively standardize non-standard data, and if fail do exception handling.

Alex Miller (Clojure team)05:05:25

@danielcompton no, there will not be a way to combine function definition with spec


are there any builtin predicates for queues in clj/cljs?


@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 [])


@john yes, sort of, with a generator included, please

Alex Miller (Clojure team)15:05:07

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 ...))

Alex Miller (Clojure team)15:05:55

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.


"how to get named spec for anonymous fn", there.