This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-04
Channels
- # aleph (8)
- # aws (14)
- # babashka (37)
- # beginners (30)
- # calva (5)
- # cider (4)
- # clj-kondo (21)
- # cljsrn (4)
- # clojure (234)
- # clojure-denmark (1)
- # clojure-europe (10)
- # clojure-france (10)
- # clojure-italy (4)
- # clojure-nl (17)
- # clojure-sanfrancisco (1)
- # clojure-spec (8)
- # clojure-uk (44)
- # clojurescript (20)
- # cursive (9)
- # datascript (2)
- # datomic (5)
- # emacs (9)
- # fulcro (50)
- # graalvm (32)
- # jackdaw (18)
- # leiningen (1)
- # malli (10)
- # meander (10)
- # nrepl (10)
- # off-topic (15)
- # pathom (20)
- # re-frame (14)
- # reagent (37)
- # reitit (7)
- # ring (1)
- # shadow-cljs (102)
- # test-check (6)
- # tree-sitter (15)
- # vim (4)
- # xtdb (2)
- # yada (1)
Are there best practices for how specs are intended to be identified with one another? I have the situation where I want to define spec ::data
via (s/def ::data ::specs/jsonb)
(where (s/def ::jsonb map?)
). I want to define a map (`spec-casters`) from specs to the functions that can be executed to transform their values (for db insertion). The spec-casters-YES-PLEASE
function (which I want to use) seems to do what I want, but I have already run into situations in development where (get spec-casters-YES-PLEASE (s/spec ::other-ns/data)) ;; => nil
. I could use spec-casters-NO-THANKS
but I would rather avoid that verbosity. This makes me wonder consider that there might be something inadvisable about this approach.
(def spec-casters-YES-PLEASE
{(s/spec ::specs/jsonb) pg-cast-jsonb})
(def spec-casters-NO-THANKS
{::specs/jsonb pg-cast-jsonb
::other-ns/data pg-cast-jsonb})
I only understand about 30% of what you're trying to do, but (s/spec ::specs/jsonb) is a spec object without well-defined equality semantics so it seems like a bad choice for a key
Ok, the fact that specs lack well-defined equality semantics suggests that I should just be more explicit and use the NO-THANKS
approach where the keys are just the namespaced keywords.
However, that seems to violate the intention of a key spec though, namely that its value should conform to it ...
but you're not conforming
you're just matching spec objects
not using them for anything