extend-abstract ^
creates a set of abstract multimethods as well as extends a set of
protocols to a given type
(extend-abstract
Envelope [IData]
:select -
:suffix -env
:prefix nil
:wrappers {-data (str "hello " %)}
:dispatch :type
:defaults {nil ([this & args] (Exception. "No input"))
-data ([this] (:hello this))})
(data-env (map->Envelope {:hello "world"}))
=> "world"
(-data (map->Envelope {:hello "world"}))
=> "hello world"
extend-all ^
transforms a protocl template into multiple extend-type expresions
(macroexpand-1
'(extend-all Magma
[(op ([x y] (% x y)))]
Number [op-number]
[List Vector] [op-list]))
=> '(do (clojure.core/extend-type Number Magma (op ([x y] (op-number x y))))
(clojure.core/extend-type List Magma (op ([x y] (op-list x y))))
(clojure.core/extend-type Vector Magma (op ([x y] (op-list x y)))))
extend-implementations ^
creates a set of implementation functions for implementation
of protocol functionality
(extend-implementations
[IData]
:wrappers (fn [form _]
(list 'str form " again")))
(data (map->Envelope {:hello "world"}))
=> "hello world again"
include ^
imports all or a selection of vars from one namespace to the current one.
(include (hara.core.base.check atom? long?))
(eval '(long? 1)) => true
(eval '(atom? 1)) => false
(include
{:fn (fn [ns sym var]
(intern ns sym (fn [x] (@var (bigint x)))))}
(hara.core.base.check bigint?))
(eval '(bigint? 1)) => true
(include
{:ns 'clojure.core}
(hara.core.base.check bigint?))
=> [#'clojure.core/bigint?]
link ^
creates links to vars that can be resolved in a controllable manner
(link
{:resolve :lazy}
(hara.core.base.check atom?))
(meta #'atom?) => {:name 'atom?, :ns *ns*}
registered-link? ^
checks if a link is registered
(registered-link? -lnk-)
=> false
registered-links ^
returns all registered links
(register-link -lnk-)
=> #'hara.module.base.link-test/-lnk-
(registered-links)
=> (contains [(exactly #'-lnk-)])
resolve-links ^
resolves all unresolved links in a background thread
(resolve-links)
unresolved-links ^
returns all unresolved links
(unresolved-links)