Public Vars

Back

find-ns (clj)

(source)

function

(find-ns sym)
Returns the namespace named by the symbol or nil if it doesn't exist.

Examples

clojure/core.typed
(ns ^:no-doc clojure.core.typed.import-macros
  (:require [clojure.core :as core]))

;copied from ClojureScript
(defmacro import-macros [ns [& vars]]
  (core/let [ns (find-ns ns)
             vars (map (core/fn [vsym]
                         {:pre [(symbol? vsym)]
                          :post [(instance? clojure.lang.Var %)]}
                         (let [v (ns-resolve ns vsym)]
                           (assert v (str "Internal error: " vsym " does not exist"))
                           v))
                       vars)
             syms (map (core/fn [^clojure.lang.Var v] 
                         {:pre [(instance? clojure.lang.Var v)]
                          :post [(symbol? %)]}
                         (core/-> v .sym (with-meta {:macro true})))
                       vars)
             defs (map (core/fn [sym var]
                         {:pre [(symbol? sym)
                                (instance? clojure.lang.Var var)]}
                         `(do (def ~sym (deref ~var))
                              ;for AOT compilation
                              (alter-meta! (var ~sym) 
                                           merge
                                           (dissoc (meta ~var) :ns :name)
                                           {:macro true})))
                       syms vars)]
    `(do ~@defs
         :imported)))
typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
  "Type annotations for the base Clojure distribution."
  #?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
  (:require [clojure.core :as cc]
            [typed.clojure :as t]
            #?(:clj [typed.ann-macros.clojure :as macros])
            #?(:clj typed.ann.clojure.jvm) ;; jvm annotations
            #?(:clj clojure.core.typed))
  #?(:clj
     (:import (clojure.lang PersistentHashSet PersistentList
                            APersistentMap #_IPersistentCollection
                            #_ITransientSet
                            IRef)
              (java.util Comparator Collection))))

cc/find-ns [t/Sym :-> (t/Nilable t/Namespace)]
cc/create-ns [t/Sym :-> t/Namespace]
#?@(:cljs [] :default [
cc/remove-ns [t/Sym :-> t/Namespace]
cc/ns-map [(t/U t/Sym t/Namespace) :-> t/Sym]
cc/ns-aliases [(t/U t/Sym t/Namespace) :-> (t/Map t/Sym t/Namespace)]
cc/the-ns [(t/U t/Sym t/Namespace) :-> t/Namespace]
cc/in-ns [t/Sym :-> nil]
cc/import [t/Any :* :-> nil]
])
cc/namespace [(t/U t/Sym t/Keyword) :-> (t/Nilable t/Str)]
cc/ns-name [(t/U t/Sym t/Namespace) :-> t/Sym]
cc/name [(t/U t/Str t/Named) :-> t/Str]
cc/identity (t/All [x] [x :-> x
                        :filters {:then (! (t/U nil false) 0)
                                  :else (is (t/U nil false) 0)}
                        :object {:id 0}])
cc/gensym [(t/? (t/U t/Sym t/Str)) :-> t/Sym]
#?@(:cljs [] :default [
cc/intern [(t/U t/Sym t/Namespace) t/Sym (t/? t/Any) :-> t/AnyVar]
])
typedclojure/typedclojure
(ns ^:no-doc clojure.core.typed.import-macros
  (:require [clojure.core :as core]))

;copied from ClojureScript
(defmacro import-macros [ns [& vars]]
  (core/let [ns (find-ns ns)
             vars (map (core/fn [vsym]
                         {:pre [(symbol? vsym)]
                          :post [(instance? clojure.lang.Var %)]}
                         (let [v (ns-resolve ns vsym)]
                           (assert v (str "Internal error: " vsym " does not exist"))
                           v))
                       vars)
             syms (map (core/fn [^clojure.lang.Var v] 
                         {:pre [(instance? clojure.lang.Var v)]
                          :post [(symbol? %)]}
                         (core/-> v .sym (with-meta {:macro true})))
                       vars)
             defs (map (core/fn [sym var]
                         {:pre [(symbol? sym)
                                (instance? clojure.lang.Var var)]}
                         `(do (def ~sym (deref ~var))
                              ;for AOT compilation
                              (alter-meta! (var ~sym) 
                                           merge
                                           (dissoc (meta ~var) :ns :name)
                                           {:macro true})))
                       syms vars)]
    `(do ~@defs
         :imported)))
juxt/jig
(ns jig.mqtt
  (:require
   jig
   [clojurewerkz.machine-head.client :as mh]
   [clojure.core.async :refer (chan >!! close!)]
   [clojure.tools.logging :refer :all])
  (:import (jig Lifecycle)))

(alter-meta!
 (find-ns 'jig.mqtt)
 assoc
 :doc "MQTT components"
 :jig/components
 [{:component 'jig.mqtt/MqttClient
   :doc "Set up a 'Machine Head' MQTT client"
   :configuration {:uri {:doc "URI to the MQTT broker"
                         :required true}}
   :provides {:init [::machine-head-client]}
   }
  {:component 'jig.mqtt/MqttSubscriber
   :doc "Subscribe to MQTT topics and place messages on a channel"
   :configuration {:channel-size {:doc "The size of the core.async channel"
                                  :required false}
                   :topics {:doc "Topics to subscribe to"
                            :required true}
                   :channel {:doc "A key within :jig/channels"}}
   :requires {:start [::machine-head-client]}
   }])
practicalli/clojure-through-code
  (refresh)
 ;; => #error {
 ;; :cause "Could not locate clojure/core/async__init.class, clojure/core/async.clj or clojure/core/async.cljc on classpath."
 ;; :via
 ;; [{:type clojure.lang.Compiler$CompilerException
 ;;   :message "Syntax error compiling at (clojure_through_code/core_async.clj:1:1)."
 ;;   :data #:clojure.error{:phase :compile-syntax-check, :line 1, :column 1, :source "clojure_through_code/core_async.clj"}
 ;;   :at [clojure.lang.Compiler load "Compiler.java" 7652]}
 ;;  {:type java.io.FileNotFoundException
 ;;   :message "Could not locate clojure/core/async__init.class, clojure/core/async.clj or clojure/core/async.cljc on classpath."
 ;;   :at [clojure.lang.RT load "RT.java" 462]}]
 ;; :trace
 ;; [[clojure.lang.RT load "RT.java" 462]
 ;;  [clojure.lang.RT load "RT.java" 424]
 ;;  [clojure.core$load$fn__6856 invoke "core.clj" 6115]
 ;;  [clojure.core$load invokeStatic "core.clj" 6114]
 ;;  [clojure.core$load doInvoke "core.clj" 6098]
 ;;  [clojure.lang.RestFn invoke "RestFn.java" 408]
 ;;  [clojure.core$load_one invokeStatic "core.clj" 5897]
 ;;  [clojure.core$load_one invoke "core.clj" 5892]
 ;;  [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
 ;;  [clojure.core$load_lib invokeStatic "core.clj" 5936]
 ;;  [clojure.core$load_lib doInvoke "core.clj" 5917]
 ;;  [clojure.lang.RestFn applyTo "RestFn.java" 142]
 ;;  [clojure.core$apply invokeStatic "core.clj" 669]
 ;;  [clojure.core$load_libs invokeStatic "core.clj" 5974]
 ;;  [clojure.core$load_libs doInvoke "core.clj" 5958]
 ;;  [clojure.lang.RestFn applyTo "RestFn.java" 137]
 ;;  [clojure.core$apply invokeStatic "core.clj" 669]
 ;;  [clojure.core$require invokeStatic "core.clj" 5996]
 ;;  [clojure.core$require doInvoke "core.clj" 5996]
 ;;  [clojure.lang.RestFn invoke "RestFn.java" 408]
 ;;  [clojure_through_code.core_async$eval7357$loading__6737__auto____7358 invoke "core_async.clj" 3]
 ;;  [clojure_through_code.core_async$eval7357 invokeStatic "core_async.clj" 3]
 ;;  [clojure_through_code.core_async$eval7357 invoke "core_async.clj" 3]
 ;;  [clojure.lang.Compiler eval "Compiler.java" 7181]
 ;;  [clojure.lang.Compiler eval "Compiler.java" 7170]
 ;;  [clojure.lang.Compiler load "Compiler.java" 7640]
 ;;  [clojure.lang.RT loadResourceScript "RT.java" 381]
 ;;  [clojure.lang.RT loadResourceScript "RT.java" 372]
 ;;  [clojure.lang.RT load "RT.java" 459]
 ;;  [clojure.lang.RT load "RT.java" 424]
 ;;  [clojure.core$load$fn__6856 invoke "core.clj" 6115]
 ;;  [clojure.core$load invokeStatic "core.clj" 6114]
 ;;  [clojure.core$load doInvoke "core.clj" 6098]
 ;;  [clojure.lang.RestFn invoke "RestFn.java" 408]
 ;;  [clojure.core$load_one invokeStatic "core.clj" 5897]
 ;;  [clojure.core$load_one invoke "core.clj" 5892]
 ;;  [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
 ;;  [clojure.core$load_lib invokeStatic "core.clj" 5936]
 ;;  [clojure.core$load_lib doInvoke "core.clj" 5917]
 ;;  [clojure.lang.RestFn applyTo "RestFn.java" 142]
 ;;  [clojure.core$apply invokeStatic "core.clj" 669]
 ;;  [clojure.core$load_libs invokeStatic "core.clj" 5974]
 ;;  [clojure.core$load_libs doInvoke "core.clj" 5958]
 ;;  [clojure.lang.RestFn applyTo "RestFn.java" 137]
 ;;  [clojure.core$apply invokeStatic "core.clj" 669]
 ;;  [clojure.core$require invokeStatic "core.clj" 5996]
 ;;  [clojure.core$require doInvoke "core.clj" 5996]
 ;;  [clojure.lang.RestFn invoke "RestFn.java" 421]
 ;;  [clojure.tools.namespace.reload$track_reload_one invokeStatic "reload.clj" 35]
 ;;  [clojure.tools.namespace.reload$track_reload_one invoke "reload.clj" 21]
 ;;  [clojure.tools.namespace.reload$track_reload invokeStatic "reload.clj" 52]
 ;;  [clojure.tools.namespace.reload$track_reload invoke "reload.clj" 43]
 ;;  [clojure.lang.AFn applyToHelper "AFn.java" 154]
 ;;  [clojure.lang.AFn applyTo "AFn.java" 144]
 ;;  [clojure.lang.Var alterRoot "Var.java" 308]
 ;;  [clojure.core$alter_var_root invokeStatic "core.clj" 5499]
 ;;  [clojure.core$alter_var_root doInvoke "core.clj" 5494]
 ;;  [clojure.lang.RestFn invoke "RestFn.java" 425]
 ;;  [clojure.tools.namespace.repl$do_refresh invokeStatic "repl.clj" 94]
 ;;  [clojure.tools.namespace.repl$do_refresh invoke "repl.clj" 83]
 ;;  [clojure.tools.namespace.repl$refresh invokeStatic "repl.clj" 145]
 ;;  [clojure.tools.namespace.repl$refresh doInvoke "repl.clj" 128]
 ;;  [clojure.lang.RestFn invoke "RestFn.java" 397]
 ;;  [clojure_through_code.undefine$eval7353 invokeStatic "NO_SOURCE_FILE" 32]
 ;;  [clojure_through_code.undefine$eval7353 invoke "NO_SOURCE_FILE" 32]
 ;;  [clojure.lang.Compiler eval "Compiler.java" 7181]
 ;;  [clojure.lang.Compiler eval "Compiler.java" 7136]
 ;;  [clojure.core$eval invokeStatic "core.clj" 3202]
 ;;  [clojure.core$eval invoke "core.clj" 3198]
 ;;  [nrepl.middleware.interruptible_eval$evaluate$fn__1245$fn__1246 invoke "interruptible_eval.clj" 87]
 ;;  [clojure.lang.AFn applyToHelper "AFn.java" 152]
 ;;  [clojure.lang.AFn applyTo "AFn.java" 144]
 ;;  [clojure.core$apply invokeStatic "core.clj" 667]
 ;;  [clojure.core$with_bindings_STAR_ invokeStatic "core.clj" 1977]
 ;;  [clojure.core$with_bindings_STAR_ doInvoke "core.clj" 1977]
 ;;  [clojure.lang.RestFn invoke "RestFn.java" 425]
 ;;  [nrepl.middleware.interruptible_eval$evaluate$fn__1245 invoke "interruptible_eval.clj" 87]
 ;;  [clojure.main$repl$read_eval_print__9110$fn__9113 invoke "main.clj" 437]
 ;;  [clojure.main$repl$read_eval_print__9110 invoke "main.clj" 437]
 ;;  [clojure.main$repl$fn__9119 invoke "main.clj" 458]
 ;;  [clojure.main$repl invokeStatic "main.clj" 458]
 ;;  [clojure.main$repl doInvoke "main.clj" 368]
 ;;  [clojure.lang.RestFn invoke "RestFn.java" 1523]
 ;;  [nrepl.middleware.interruptible_eval$evaluate invokeStatic "interruptible_eval.clj" 84]
 ;;  [nrepl.middleware.interruptible_eval$evaluate invoke "interruptible_eval.clj" 56]
 ;;  [nrepl.middleware.interruptible_eval$interruptible_eval$fn__1278$fn__1282 invoke "interruptible_eval.clj" 152]
 ;;  [clojure.lang.AFn run "AFn.java" 22]
 ;;  [nrepl.middleware.session$session_exec$main_loop__1348$fn__1352 invoke "session.clj" 218]
 ;;  [nrepl.middleware.session$session_exec$main_loop__1348 invoke "session.clj" 217]
 ;;  [clojure.lang.AFn run "AFn.java" 22]
 ;;  [java.lang.Thread run "Thread.java" 833]]}

;; ;; ns-unalias to the rescue!
;; user=> (ns-unalias (find-ns 'com.tizra.layout-expander) 'xml)
;; nil