This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-01
Channels
- # announcements (14)
- # architecture (30)
- # aws (34)
- # babashka (18)
- # beginners (114)
- # biff (5)
- # calva (128)
- # clerk (155)
- # clj-kondo (60)
- # clojure (82)
- # clojure-dev (25)
- # clojure-europe (20)
- # clojure-nl (1)
- # clojure-norway (17)
- # clojure-spec (13)
- # clojure-uk (3)
- # community-development (4)
- # core-logic (4)
- # cursive (5)
- # datomic (21)
- # deps-new (13)
- # emacs (5)
- # funcool (5)
- # graphql (3)
- # hyperfiddle (1)
- # introduce-yourself (1)
- # jobs (2)
- # kaocha (1)
- # london-clojurians (1)
- # lsp (13)
- # malli (16)
- # off-topic (6)
- # other-languages (1)
- # pathom (18)
- # re-frame (23)
- # releases (1)
- # remote-jobs (2)
- # tools-build (1)
- # tools-deps (12)
- # vscode (1)
- # xtdb (27)
question about resolving specs: is there a way to require a spec out of the global registry as if it were a regular var in a ns? I have discovered that I can't do something like (require [foospec.bar :refer [baz]])
presumably because baz
is not interned in the foospec.bar
ns but is instead in the registry? Is that correct?
correct, specs are not vars
you could put a spec in a var with (def my-spec (s/get-spec ::foo))
if you wanted to for some reason
no, not necessary, I'm fine with it being in the registry. So if require the whole foospec.bar
ns say as fspec
and then resolve ::fspec/baz
its just looking in the registry for that fully qualified name?
that's how I have been doing it at any rate
not sure I understand "require the whole foospec.bar
ns say as fspec
" but fspecs are also just specs in the registry (but their keys are fully-qualified symbols, not keywords)
s/fdef
just creates a spec with s/fspec
, then adds it to the registry (which is just a map) with the fq symbol as the key
sorry, that was a poor choice of alias on my part
I am not talking about function specs, just any spec in general
@U03QBKTVA0N Don't forget there's :as-alias
now in a require so you can create an alias for resolving Spec names without having to actually load a real namespace.
(ns using.specs
(:require [i.do-not.exist :as-alias idne]))
::idne/bar ;=> i.do-not.exist/bar
and no i/do_not/exist.clj
file is needed for this.oh thanks @U04V70XH6 I did not know about as-alias
. That's helpful.