(extend-abstract typesym protocolsyms & {:as options})
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"
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-implementations protocolsyms & {:as options})
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"
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"
(map-walk obj mapobj args f-obj f-nil f-nonmap)
Helper function for evaluation of various utility functions within the namespace
(map-walk :hello {#{:hello} (fn [k arg1] (str (name k) " world " arg1))} ["again"] identity (fn [_ _ _] :none) (fn [obj func arg1] (func obj arg1))) => "hello world again"
Helper function for evaluation of various utility functions within the namespace (map-walk :hello {#{:hello} (fn [k arg1] (str (name k) " world " arg1))} ["again"] identity (fn [_ _ _] :none) (fn [obj func arg1] (func obj arg1))) => "hello world again"
(map-walk-submap m search-key)
Gets a submap depending on whether it is a key or it is a key witthin a hashset
(map-walk-submap {:hello "world"} :hello) => "world"
(map-walk-submap {#{:hello} "world"} :hello) => "world"
Gets a submap depending on whether it is a key or it is a key witthin a hashset (map-walk-submap {:hello "world"} :hello) => "world" (map-walk-submap {#{:hello} "world"} :hello) => "world"
(protocol-all typesym protocolsym {:keys [select prefix suffix] :as options})
extends all methods on the type for a single protocol
(protocol-all 'Envelope 'IData '{:select - :suffix -env :prefix nil}) => '(let [function [(defmulti data-env (fn [this] this))]] (extend-type Envelope IData (-data [this] (data-env this))) function)
extends all methods on the type for a single protocol (protocol-all 'Envelope 'IData '{:select - :suffix -env :prefix nil}) => '(let [function [(defmulti data-env (fn [this] this))]] (extend-type Envelope IData (-data [this] (data-env this))) function)
(protocol-basis protocol select prefix suffix)
Helper function that transforms the functions in the protocol to the neccessary format in preparation for extend-abstract and extend-implementations
(defprotocol IData (-data [this]))
(defrecord Envelope [])
(defprotocol IVal (-set [this val]) (-get [this]))
(protocol-basis IVal '- 'pre- '-tail) => (contains '({:args [this], :fn pre-get-tail, :name -get} {:args [this val], :fn pre-set-tail, :name -set}) :in-any-order)
Helper function that transforms the functions in the protocol to the neccessary format in preparation for extend-abstract and extend-implementations (defprotocol IData (-data [this])) (defrecord Envelope []) (defprotocol IVal (-set [this val]) (-get [this])) (protocol-basis IVal '- 'pre- '-tail) => (contains '({:args [this], :fn pre-get-tail, :name -get} {:args [this val], :fn pre-set-tail, :name -set}) :in-any-order)
(protocol-default-form basis defaults)
creates a :default defmethod form from a protocol basis
(protocol-default-form '{:args [this], :fn data-env, :name -data} '([this & args] (Exception. "No input"))) => '(defmethod data-env :default [this & args] (Exception. "No input"))
creates a :default defmethod form from a protocol basis (protocol-default-form '{:args [this], :fn data-env, :name -data} '([this & args] (Exception. "No input"))) => '(defmethod data-env :default [this & args] (Exception. "No input"))
(protocol-extend-type typesym protocolsym all-basis {:keys [wrappers]})
utility to create an extend-type form (protocol-extend-type 'Type 'IProtocol '[{:args [this], :fn data-env, :name -data}] '{:wrappers (fn [form basis] (concat ['apply] form [[]]))}) => '(extend-type Type IProtocol (-data [this] (apply data-env this [])))
utility to create an extend-type form (protocol-extend-type 'Type 'IProtocol '[{:args [this], :fn data-env, :name -data}] '{:wrappers (fn [form basis] (concat ['apply] form [[]]))}) => '(extend-type Type IProtocol (-data [this] (apply data-env this [])))
(protocol-extend-type-function basis wrappers)
utility to create a extend-type function with template and macros
(protocol-extend-type-function '{:args [this], :fn data-env, :name -data} '{-data (fn [form basis] (concat ['apply] form [[]]))}) => '(-data [this] (apply data-env this []))
utility to create a extend-type function with template and macros (protocol-extend-type-function '{:args [this], :fn data-env, :name -data} '{-data (fn [form basis] (concat ['apply] form [[]]))}) => '(-data [this] (apply data-env this []))
(protocol-extend-type-wrappers basis wrappers form)
applies form template for simple template rewrites
(protocol-extend-type-wrappers '{:args [this], :fn data-env, :name -data} '{-data (process %)} '(data-env this)) => '(process (data-env this))
(protocol-extend-type-wrappers '{:args [this], :fn data-env, :name -data} '{-data (fn [form basis] (concat ['apply] form [[]]))} '(data-env this)) => '(apply data-env this [])
applies form template for simple template rewrites (protocol-extend-type-wrappers '{:args [this], :fn data-env, :name -data} '{-data (process %)} '(data-env this)) => '(process (data-env this)) (protocol-extend-type-wrappers '{:args [this], :fn data-env, :name -data} '{-data (fn [form basis] (concat ['apply] form [[]]))} '(data-env this)) => '(apply data-env this [])
(protocol-implementation protocolsym
{:keys [select prefix suffix wrappers] :as options})
returns the protocol implementation
(protocol-implementation 'IData {:wrappers '{-data (fn [form basis] (concat ['apply] form [[]]))}}) => '((clojure.core/defn data [this] (apply hara.module.base.abstract-test/-data this [])))
returns the protocol implementation (protocol-implementation 'IData {:wrappers '{-data (fn [form basis] (concat ['apply] form [[]]))}}) => '((clojure.core/defn data [this] (apply hara.module.base.abstract-test/-data this [])))
(protocol-implementation-function basis wrappers pns)
Creates a form for implementation of the protocol
(protocol-implementation-function (first (protocol-basis IData '- nil '-env)) '{-data (fn [form basis] (concat ['apply] form [[]]))} (protocol-ns IData)) => '(clojure.core/defn data-env [this] (apply hara.module.base.abstract-test/-data this []))
Creates a form for implementation of the protocol (protocol-implementation-function (first (protocol-basis IData '- nil '-env)) '{-data (fn [form basis] (concat ['apply] form [[]]))} (protocol-ns IData)) => '(clojure.core/defn data-env [this] (apply hara.module.base.abstract-test/-data this []))
(protocol-multi-form basis dispatch)
creates a defmulti form from a protocol basis
(protocol-multi-form '{:args [this], :fn data-env, :name -data} '{#{-data} (-> % :meta :type)}) => '(defmulti data-env (fn [this] (-> this :meta :type)))
creates a defmulti form from a protocol basis (protocol-multi-form '{:args [this], :fn data-env, :name -data} '{#{-data} (-> % :meta :type)}) => '(defmulti data-env (fn [this] (-> this :meta :type)))
(protocol-multimethods all-basis {:keys [defaults dispatch]})
creates a set of defmulti and defmethods for each entry in all-basis
(protocol-multimethods '[{:args [this], :fn data-env, :name -data}] {:defaults '([this & args] (Exception. "No input")) :dispatch '(-> % :meta :type)}) => '((defmulti data-env (fn [this] (-> this :meta :type))) (defmethod data-env :default [this & args] (Exception. "No input")))
creates a set of defmulti and defmethods for each entry in all-basis (protocol-multimethods '[{:args [this], :fn data-env, :name -data}] {:defaults '([this & args] (Exception. "No input")) :dispatch '(-> % :meta :type)}) => '((defmulti data-env (fn [this] (-> this :meta :type))) (defmethod data-env :default [this & args] (Exception. "No input")))
(protocol-ns protocol)
gets the namespace of the protocol
(protocol-ns IData) => "hara.module.base.abstract-test"
gets the namespace of the protocol (protocol-ns IData) => "hara.module.base.abstract-test"
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close