This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-03
Channels
- # aws-lambda (6)
- # beginners (38)
- # boot (39)
- # cider (44)
- # cljs-dev (9)
- # cljsrn (96)
- # clojure (142)
- # clojure-dev (6)
- # clojure-dusseldorf (8)
- # clojure-greece (45)
- # clojure-ireland (3)
- # clojure-italy (7)
- # clojure-norway (6)
- # clojure-russia (26)
- # clojure-sg (16)
- # clojure-spec (31)
- # clojure-uk (39)
- # clojurescript (125)
- # cursive (38)
- # datascript (4)
- # datomic (18)
- # emacs (34)
- # figwheel (2)
- # hoplon (3)
- # immutant (23)
- # jobs (1)
- # lambdaisland (2)
- # lumo (13)
- # off-topic (77)
- # om (8)
- # onyx (9)
- # pedestal (2)
- # play-clj (1)
- # re-frame (52)
- # reagent (3)
- # rum (4)
- # spacemacs (2)
- # specter (4)
- # unrepl (37)
- # untangled (8)
- # vim (79)
- # yada (1)
"wrap-error" strikes me as misleading. you're really just wrapping a fn, which may not have an error, no?
The doc seems to imply that s/alt
is ordered choice, i.e. the alternatives will be tested in order and the first match returned. Is that correct?
@cfleming yes from the doc string: "Returns a regex op that returns a map entry containing the key of the first matching pred and the corresponding value. "
greetings! I am getting
(s/exercise :dsc/patch 1)
=> ExceptionInfo Couldn't satisfy such-that predicate after 100 tries. clojure.core/ex-info (core.clj:4725)
is there a way to narrow error location down? (:dsc/patch is a compound spec, ~30 lines long)I really wished spec was spec'ed. Just lost som time on why s/keys was valid on my invalid maps. Reason? I used :un-req instead of :req-un
is there something built in for what I'am trying to achieve (generator for next-id, which never returns a duplicate)?
here I'd like to avoid custom reduce-through-hashmap predicate, and combine s/keys
and s/map-of
specs instead
that one fails because s/and
results in empty set of valid keys. s/merge
will result in an empty set too.
it seems like I need a custom predicate after all:
(s/def :datascript/map-with-current-tx (s/keys :req [:db/current-tx]))
(s/def :datascript/map-with-tempids-lookup (s/map-of :datascript/temp-id :datascript/actual-id))
(def gen-tempids
(tgen/let [ids (s/gen :datascript/map-with-tempids-lookup)
ctx (s/gen :datascript/map-with-current-tx)]
(merge ids ctx)))
(s/def :datascript/tempids
(s/with-gen
(fn [m]
(and
(s/valid? :datascript/map-with-current-tx m)
(s/valid? :datascript/map-with-tempids-lookup (dissoc m :db/current-tx))))
(constantly gen-tempids)))
@souenzzo tried that right now. it also gives me
ExceptionInfo Couldn't satisfy such-that predicate after 100 tries. clojure.core/ex-info (core.clj:4725)
has anyone been able to use generators with cljs? I’m not really sure how (I don’t even see gen
defined in the cljs.spec.impl.gen
ns, and my google foo is failing
@lwhorton yes, but I don't remember off the top of my head what the differences with clj were...
tl;dr - looks like I import the clojure.test.check.generators
ns, and use that in conjunction with clojure.spec/gen
@lwhorton: sure, np. perhaps better examples here: https://github.com/bhagany/snowth/blob/master/src/snowth/astro.cljs
Hi. Trying out spec and running into a problem right away. Simply adding [clojure.spec.alpha :as s] to a :require section in my clojure file, and then trying to load that file in the repl (Leiningen) via use gives me this error: java.lang.ClassCastException: clojure.spec.alpha$regex_spec_impl$reify__1340 cannot be cast to clojure.lang.IFn When I use require instead of use, it seems fine. Anything I'm doing wrong/ known bug?
actually, scrap that... I get this error with either use or require whenever I pass in the :reload-all flag
Yes, there’s an AOT-related issue at present with the version of spec.alpha
that Clojure 1.9.0 Alpha 16 pulls in. If you explicitly depend on org.clojure/spec.alpha "0.1.108"
the problem should go away.
It specifically seems to affect REPL workflows and anything that reloads code.
thanks!