This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-06
Channels
- # babashka (31)
- # beginners (108)
- # calva (6)
- # clj-kondo (62)
- # cljsrn (5)
- # clojure (29)
- # clojure-australia (2)
- # clojure-europe (17)
- # clojure-nl (2)
- # clojure-spec (5)
- # clojure-uk (7)
- # clojurescript (25)
- # code-reviews (1)
- # datomic (13)
- # deps-new (7)
- # editors (1)
- # emacs (31)
- # figwheel-main (3)
- # garden (4)
- # graalvm (18)
- # helix (10)
- # improve-getting-started (12)
- # jobs (3)
- # lsp (20)
- # malli (12)
- # off-topic (7)
- # polylith (30)
- # re-frame (10)
- # remote-jobs (2)
- # shadow-cljs (18)
- # spacemacs (5)
- # sql (11)
- # tools-deps (10)
- # vim (9)
- # xtdb (1)
remembering typescript has https://github.com/DefinitelyTyped/DefinitelyTyped and wondering if it would be sensible to do something similar for clj* libraries and malli
Motivating example for me most recently is datomic's api - it gives annoying and obtuse errors if you pass bad data and spec'ing inputs at dev time would be helpful
(alter-meta!
#'d/transact
assoc
:malli/schema
[:=>
[:cat some? [:map [:tx-data some?]]]
[:map
[:db-before any?]
[:db-after any?]
[:tx-data any?]
[:tempids any?]]])
idk what the best approach is - maybe artificially associate with a namespace at first instead of the metadata?
(defn register-possibly-nonexistant-schema
[var-path schema]
(m/-register-function-schema! (symbol (namespace var-path))
(symbol (name var-path))
schema
nil))
(register-possibly-nonexistant-schema
'datomic.client.api/transact
[:=>
[:cat some? [:map [:tx-data some?]]]
[:map
[:db-before any?]
[:db-after any?]
[:tx-data any?]
[:tempids any?]]])
or maybe the library has its own registry you can select from and merge into your own / the global registry
Pick a top level namespaces that does all the (m/=> ...)
declarations, and they can include it themselves if they feel so inclined?
Clj-kondo has this for linting. Maybe malli could adopt a similar pattern?
that would be interesting. One of my goals with is to get a robust schema inferrer: for runtime for inferring from schemas from samples, but could be used to pull out schemas from tests (annotate functions in dev-mode to infer input & output) schemas. Not a silver bullet, but would be “for free”. Manually writing functios schmas is always better, but also, a lot of work.