Fork me on GitHub
#clojure-spec
<
2017-05-13
>
danielcompton02:05:50

In https://clojure.org/about/spec#_minimize_intrusion it says "Don’t require that people e.g. define their functions differently."

danielcompton02:05:01

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?

danielcompton02:05:14

If I do want to define my functions with my spec?

lincpa02:05:47

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

lincpa02:05:30

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

lincpa02:05:17

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

misha09:05:04

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

john15:05:36

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

misha15:05:55

@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

misha15:05:07

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

misha15:05:47

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.

misha16:05:16

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