On Friday, June 10, 2016 at 8:58:10 AM UTC-4, Steen Larsen wrote: > > Hi, > > I am playing around with spec, and really like it so far, but have a > problem using fdef with maps. I am obviously missing something trivial, but > the following example gives a, to me, weird error > > (defn command [m] > "hello") > > (s/def ::test integer?) > > (s/fdef command > :args (s/keys :req [::test]) > :ret string?) > > Running > > (command {:test 3}) > > gives > > Call to #'cqrs-spec.core/command did not conform to spec: val: > ({:test 3}) fails at: [:args] predicate: map? :clojure.spec/args > ({:test 3}) > > {:clojure.spec/problems > {[:args] {:pred map?, :val ({:test 3}), :via [], :in []}}, > :clojure.spec/args ({:test 3})} > > which seems to say that the function receives a list and not a map, even > though it obviously does. Now why is that ? > > /Steen >
At a guess, it looks like it's checking that *all the arguments* constitutes a map, rather than that *the first argument* constitutes a map. (Also: what is typically the type of the last argument when calling apply?) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.