Skip to content

Commit

Permalink
all-ns doesn't work with all envs?
Browse files Browse the repository at this point in the history
  • Loading branch information
ikitommi committed Jan 5, 2024
1 parent 9e24c3b commit e5146b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/malli/edn.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[malli.core :as m]))

(defn -parse-string [x]
(edamame/parse-string x {:var resolve, :regex true, :fn true}))
(edamame/parse-string x {:regex true, :fn true, :var identity}))

(defn write-string
([?schema]
Expand Down
7 changes: 6 additions & 1 deletion src/malli/registry.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,15 @@
(-schema [_ type] (-schema (registry @db) type))
(-schemas [_] (-schemas (registry @db)))))

(defn -find-loaded-var [s]
(->> (all-ns) (mapcat ns-publics) (some (fn [[_ v]] (if (= s (.toSymbol v)) v)))))

(defn var-registry []
(reify
Registry
(-schema [_ type] (if (var? type) @type))
(-schema [_ type] (cond
(var? type) @type
(and (list? type) (= 'var (first type)) (= 2 (count type))) (-find-loaded-var (second type))))
(-schemas [_])))

(def ^:dynamic *registry* {})
Expand Down

0 comments on commit e5146b2

Please sign in to comment.