Fork me on GitHub
#clojure-spec
<
2019-10-29
>
jumar07:10:48

Looking at spectrum, I can't figure out how to use it: https://github.com/arohner/spectrum I know it's (still) not recommended for any kind of use, but I was curious about what it can do. However, I don't even know what kind of output can I expect from it. Trying the most basic example doesn't produce anything useful:

(defn foo [i]
  (inc i))

(f/infer-var #'foo)
;;=> couldn't find analysis for #'clojure-experiments.spectrum/foo

;; throws AssertionError
#_(f/infer-form '(foo 3))
Using spectrum 0.2.5; code is here: https://github.com/jumarko/clojure-experiments/blob/master/src/clojure_experiments/spectrum.clj#L11

jumar07:10:54

Is anybody using this tool and if so how?

danielneal09:10:45

as far as I know it’s still all in development and not usable yet

arohner21:10:47

It’s not ready yet. master has much newer code, but is also not ready.

jumar05:10:43

Hmm. looking forward to hearing more in the future then

ataggart21:10:23

I'm digging into it now, but does anyone have a guess as to what might be causing this?

user=> (require '[clojure.tools.logging :as log])
Syntax error macroexpanding clojure.core/defn at (clojure/tools/logging/impl.clj:241:1).
THIS - failed: vector? at: [:fn-tail :arity-1 :params] spec: :clojure.core.specs.alpha/param-list
THIS - failed: (or (nil? %) (sequential? %)) at: [:fn-tail :arity-n :bodies] spec: :clojure.core.specs.alpha/params+body
The line of code referenced above: https://github.com/clojure/tools.logging/blob/tools.logging-0.5.0/src/main/clojure/clojure/tools/logging/impl.clj#L241

ataggart21:10:56

I'm not yet sufficiently fluent in spec-error-ese.

andy.fingerhut21:10:40

@ataggart Most likely an older version of clojure.tools.logging from before Clojure 1.9 was released, that contains some old syntax that Clojure 1.9's and later's stricter checking rejects, and someone has since fixed with a later tools.logging release.

ataggart21:10:13

I'm using 0.5.0, which is the latest version. And that "someone" would be me. 😛

ataggart21:10:56

deps hell once again

andy.fingerhut21:10:57

Sorry, I was going for an answer appropriate for 99% of similar questions. Looking at the line of code now...

seancorfield21:10:45

(! 775)-> clojure -Sdeps '{:deps {org.clojure/tools.logging {:mvn/version "0.5.0"}}}'
Clojure 1.10.1
user=> (require '[clojure.tools.logging :as log])
nil
user=> 
Something in your environment @ataggart?

seancorfield21:10:11

(and I did wonder if a version conflict was bringing in an older version)

seancorfield21:10:37

FWIW, we use tools.logging 0.5.0 at work with Clojure 1.10.1 -- which includes all the Spec checking on defn -- and we don't see any problems.

seancorfield21:10:51

What other dependencies have you got in play?

ataggart21:10:52

Yep, I'm confident it's a deps issue. I'll keep digging. Aside, any guess on what that error means?

seancorfield21:10:32

It's a badly formed defn. Expecting an argument vector or sequence of pairs of arg vectors / bodies.

andy.fingerhut21:10:39

It mentions param-list, so my first guess would be it thinks the defn parameter list is not a vector

seancorfield21:10:07

Are you using lein/boot/clj? What does your deps tree show? Could it be a badly-behaved plugin patching stuff?

ataggart21:10:37

I'll find out and report back.

ataggart22:10:53

So, I changed the version to 0.4.1, same error. Changed it back to 0.5.0, and the error is gone....

andy.fingerhut22:10:38

Please keep your gremlins away from my computer.

ataggart22:10:36

The vision of a world of spec'd libraries without versions can't come soon enough.

ataggart22:10:06

Back to work....

Alex Miller (Clojure team)23:10:18

maybe a cached classpath? changing the deps file would invalidate the cache

Alex Miller (Clojure team)23:10:41

so any change would have forced an update

Alex Miller (Clojure team)23:10:08

if you're ever not sure with clojure, adding an -Sforce can force that regardless

👍 4