Liking cljdoc? Tell your friends :D

pronto.lens


assoc-ifclj

(assoc-if m k v)
source

assoc-or-elseclj

(assoc-or-else m k v f)
source

clear-fieldclj

(clear-field m k)
source

clear-field!clj

(clear-field! m k)
source

hintcljmacro

(hint proto-map clazz mapper)

Create a new hint for proto-map for use by p-> calls. clazz must resolve to the Java protobuf class of the underlying POJO contained within proto-map. mapper must resolve to a mapper var created via defmapper.

For example:

(p/p-> (p/hint my-map MyClass my-mapper) :field_0 field_1).

This is equivalent to writing (p/p-> my-map :field_0 :field_1), except that the produced code will be optimized using the hint of the underlying type.

See also: with-hints

Create a new hint for `proto-map` for use by p-> calls.
`clazz` must resolve to the Java protobuf class of the underlying POJO contained within `proto-map.`
`mapper` must resolve to a mapper var created via `defmapper`.

For example:

`(p/p-> (p/hint my-map MyClass my-mapper) :field_0 field_1)`.

This is equivalent to writing `(p/p-> my-map :field_0 :field_1)`, except that the
produced code will be optimized using the hint of the underlying type.

See also: `with-hints`
sourceraw docstring

p->cljmacro

(p-> x & forms)

Like -> but meant to be used where the initial expression evaluates to a proto-map. Under the hood, p-> will operate on a transient version of the proto-map and persistent! it back when done. Expressions will be pipelined as much as possible (but never reordered) such that (p-> person-proto (assoc-in [:pet :name] "patch") (assoc-in [:pet :kind] :cat)) will only generate a single instance of a pet transient map to which both operations will be applied in succession.

Like `->` but meant to be used where the initial expression evaluates to a proto-map. Under the hood, `p->` will operate on a transient version of the proto-map and `persistent!` it back when done. Expressions will be pipelined as much as possible (but never reordered) such that `(p-> person-proto (assoc-in [:pet :name] "patch") (assoc-in [:pet :kind] :cat))` will only generate a single instance of a pet transient map to which both operations will be applied in succession.
sourceraw docstring

pcond->cljmacro

(pcond-> expr & clauses)

Equivalent to cond->. See p->

Equivalent to cond->. See `p->`
sourceraw docstring

try-hintclj

(try-hint form clazz mapper)
source

with-hintscljmacro

(with-hints hints & body)

Takes a vector of hints (see hint), and introduces a scope within which all hinted variables will be type hinted in p-> calls, then executes & returns the value of body.

For example:

(defn foo [m] (p/with-hints [(p/hint m MyClass my-mapper)] {:height (p/p-> m :height) :name (p/p-> m :name)}))

Since m is hinted in the scope, both p-> calls will use the hint to produce more performant code.

Note that with-hints only applies to p-> calls directly within body, and not recursively. Therefore, the following code will not be hinted:

` (defn get-person-name [person-proto-map] (p/p-> person-proto-map :name))

(with-hints [(p/hint my-map MyClass my-mapper)] (get-person-name my-map )) `

Takes a vector of hints (see `hint`), and introduces a scope within which all hinted variables will be type hinted in `p->` calls, then executes & returns the value of `body.`

For example:

`(defn foo [m]
   (p/with-hints [(p/hint m MyClass my-mapper)]
     {:height (p/p-> m :height)
      :name   (p/p-> m :name)}))`

Since `m` is hinted in the scope, both p-> calls will use the hint to produce more performant code.

Note that with-hints only applies to p-> calls directly within `body`, and not recursively. Therefore, the following code will not be hinted:

`
(defn get-person-name [person-proto-map]
  (p/p-> person-proto-map :name))

(with-hints
  [(p/hint my-map MyClass my-mapper)]
  (get-person-name my-map ))
`
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close