Fork me on GitHub

Is there any way to leverage spec while writing "interpreters/transpilers" like hiccup which seem to be typically implemented by writing a defmethod for each operator. One disadvantage I've noticed about having these things as data is that when authoring the data, you don't get niceties like editor completion that you would get if it was actual code.


Oh. I see this was discussed literally yesterday. Sorry. Are multi-methods one of the cases that aren't easily fixable?


I think it’s possible to make them work, but haven’t worked on doing so.


It occurred to me today that for my use-case, I think I can work around it with a macro that expands to a (defmethod, defn) pair and then write fspecs against the defn.


yes, that should work


Is it customary to spec string length with coll-of characters with :count?


In most cases, I wouldn’t use coll-of for strings as that implies anything that is a sequential view of characters (lists, vectors, seqs)


prob better to do something like (s/and string? #(= 3 (count %)))


@alexmiller is almost possible* specify strings/routing with spec For example: (s/or :nums (s/coll-of #{"1" "2" "3" "4"}) :not-nums (s/coll-of #{"a" "e" "i" "o" "u"})) * with almost possible I mean: you can do with collections of chars. There is plans to do (s/string string-spec) or something like?


no plans currently


we already have string regex matching - use that


spec’s regex stuff will never be anywhere near as fast or as full-featured as the excellent regex engine already built into java


if you want gen, Gary’s regex stuff in test.chuck is pretty cool


Yeah, a big +1 for test.chuck's regex generator -- we love that!


I thought about using the specifications to do string routing. Trying to do something better than bidi, I realized spec would do that. Bidi gives you a data/dsl form do describe strings [[:foo :bar :my-path1] [:foo :my-path0]] Then, bidi "conform" this string and returns the conformed [:my-path1 {:foo "username" :bar "project-name"}] It's very close to spec (s/or :my-path (s/cat :foo string-wo-bar? :bar string-wo-bar?))...


Hi, I'm just getting started w/spec. I just added clojure 1.9 to my project.clj and immediately get a huge spec error at startup. Is it usually difficult to upgrade a project from 1.8 to 1.9?


kind of hard to say, in general, anything that spec complains about 1.9 is also broken in 1.8, 1.8 just isn't checking


@dealy One place to start looking is which lists libraries that clojure.spec found bugs in, most of which have been fixed/updated.


It seems to be failing on my require statement, the error msg doesn't hlep much: In: [2] val: (quote :as) fails at: [:args :exclude :op :spec] predicate: #{:exclude}


it repeats that error several times


its on the first line of the first file it tries to compile


What does your require look like?


its about 21 lines, should I post it here?


Use a snippet (via the + button on the left)


are you using core.async I vaguely recall there being a gnarly bug that looks something like that if you aren't on the latest or so release


yes using core.async


Interesting -- core.async isn't listed on that page above so I guess it had been updated/fixed before that page was created -- good catch @hiredman !


Yeah, I suspect a lot of people working with core.async in any way are adding it as an exclusion and pulling in a new version directly.


so that is an example of a similar issue, fixed by bumping core.async versions


well that helped some, at least the program went further before spewing errors, I didn't realize that there were gonna be these kinds of problems just upgrading to 1.9 ugh


1.9 has specs on core that will find errors that were silently ignored in the past. so, it’s good! but also frustrating at times. many of the most popular libs have been fixed up long ago.


any idea what is causing this: Error refreshing environment: java.lang.NoSuchMethodError:;Ljava/lang/Object;)V, compiling:(closure.clj:100:1) I'm using cljs 1.9.908


you should check your build tool for conflicting versions of whatever comes from


it was guava, upgrading to the latest cljs caused a conflict I guess, its working now

Oliver George23:08:07

It might be mild OCD but I find it quite inconvenient to come up with qualified keywords when writing function specs.

Oliver George23:08:37

I think what I want is a more adhoc/flexible way to create aliases.


Likely coming in the future (but not 1.9)


Waiting to 2.o


you mean 1.10 :)

Oliver George23:08:52

For example:

(s/def ::session (s/keys :req [:oauth2/csrf-token]))
(s/def ::params (s/keys :req-un [::code ::params]))
(s/fdef oauth2-success :args (s/cat :req (s/keys :req-un [::params ::session])))

Oliver George23:08:23

This is a ring handler. If I want to spec several handlers in one namespace the ::params key needs to be unique.

Oliver George23:08:47

So I end up wanting qualified keywords with a namespace unique to the function symbol

Oliver George23:08:01

e.g. ::oauth-success/params

Oliver George23:08:38

I can do it long hand. :my-app.handlers.oauth-success/params

Oliver George23:08:15

In CLJ I can declare the alias (but not CLJS) and then do ::oauth-success/params but even that is pretty heavy handed.