This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-06
Channels
- # announcements (4)
- # beginners (132)
- # calva (37)
- # chlorine-clover (60)
- # cider (1)
- # clara (12)
- # clj-kondo (40)
- # cljs-dev (109)
- # clojure (76)
- # clojure-dev (19)
- # clojure-europe (8)
- # clojure-france (17)
- # clojure-nl (4)
- # clojure-sg (1)
- # clojure-spec (14)
- # clojure-uk (7)
- # clojurescript (98)
- # conjure (96)
- # cursive (15)
- # data-science (2)
- # datalog (11)
- # datomic (24)
- # emacs (17)
- # figwheel-main (3)
- # fulcro (45)
- # jobs-discuss (1)
- # kaocha (3)
- # malli (2)
- # nrepl (1)
- # off-topic (135)
- # portal (2)
- # re-frame (17)
- # reagent (11)
- # reitit (4)
- # sci (60)
- # shadow-cljs (75)
- # spacemacs (3)
- # sql (32)
- # tools-deps (79)
- # vim (88)
- # xtdb (4)
I keep wanting ::x/blah to expand to :current.namespace$x/blah
when there's no x alias. It'd open up "private namespaces" for spec use.
My use case is CLJS function arg specs. I have many fns in a ns. They expect different things from a :db key passed in as context. (re-frame handlers)
With the proposed change I could do things like this
(ns app.events (:require [clojure.spec.alpha :as s]))
(defn event1 [{:keys [db]}] ...)
(defn event2 [{:keys [db]}] ...)
(s/fdef event1 :args (s/cat :ctx (s/keys :req-un [::event1/db]))
(s/def ::event1/db (s/keys :req-un [::ddb])))
(s/fdef event2 :args (s/cat :ctx (s/keys :req-un [::event2/db]))
(s/def ::event2/db (s/keys :req-un [::form])))
Perhaps a macro would do the job so could add to replace keyword namespaces in a form
(rename-keyword-ns {*ns* :app.events$event1)
(s/fdef event1 (s/cat :ctx (s/keys :req-un [::db]))
(s/def ::db (s/keys :req-un [::ddb]))))
I suspect Spec 2 (a.k.a. what will eventually become just clojure.spec
🙂 ) will help you here because you can define a schema
will all the possible keys with their specs, all in one place -- and then you can select
the specific keys that are required for each individual handler.
Good point. If/when that lands it'll be an improvement.
I guess it'd look something like this...
(ns app.events (:require [clojure.spec2 :as s]))
(defn event1 [{:keys [db]}] ...)
(defn event2 [{:keys [db]}] ...)
(s/def ::ctx (s/schema {:db ::db}))
(s/def ::db (s/schema {:ddb ::ddb :form ::form}))
(s/fdef event1 :args (s/cat :ctx (s/select ::ctx [:db {:db [:ddb]}]))
(s/fdef event2 :args (s/cat :ctx (s/select ::ctx [:db {:db [:form]}]))
(Guessing at the unqualified key bits)
hi, does clojure.spec.test.alpha/check
run its test cases in sequence or in parallel ?
parallel via pmap
any way to tell it to do sequential? because my code under test is already parallel and is kicking off a bunch of promises
not currently