Liking cljdoc? Tell your friends :D

futils.named

futils library, nameization.

futils library, nameization.
raw docstring

applyclj

(apply f & args)

Like apply but works on named arguments. Takes function f and a list of arguments to be passed, were the last argument should be a map that will be decomposed and passed as named arguments.

Returns the result of calling f.

Like apply but works on named arguments. Takes function f and a list of
arguments to be passed, were the last argument should be a map that will be
decomposed and passed as named arguments.

Returns the result of calling f.
raw docstring

compclj

(comp)
(comp f)
(comp f & more)

Takes a set of functions that accept named arguments and returns a function object that is the composition of those functions. The returned function takes named arguments, applies the rightmost of functions to the arguments, the next function (right-to-left) to the result, etc.

Each function should return a map or a sequential collection (see :use-seq switch) that will be used to generate named arguments for the next function in the execution chain. If a function does not return a map its resulting value will be assigned to a key of newly created map. The default name of this key will be :out unless the option :map-output had been used (see the explanations below).

The returned value of the last called function is not transformed in any way and there is no need for it to be a map.

Functions can be expressed as function objects or as maps. In the second case the map must contain :f key with function object assigned to it and may contain optional, controlling options which are:

  • :merge-args nil (default) or true or a key,
  • :map-output nil (default) or true or a key,
  • :rename-keys nil (default) or a map,
  • :post-rename nil (default) or a map,
  • :use-seq nil (default) or true,
  • :apply-raw nil (default) or true.

The :merge-args option, when is not set to false nor nil, causes function arguments to be merged with a returned map. If the key is given they all will be stored under specified key of this map. If the assigned value is set to true then they will be merged. If two keys are the same the association from arguments is overwritten by the entry being returned by a function.

The :map-output causes the returned value to be stored under a specified key of a resulting map. If the option value is set to true then the key name will be :out.

The :rename-keys option causes keys of a resulting map to be renamed according to the given map. The transformation will be performed on a returned value (if it's a map), before any other changes (output mapping or arguments merging).

The :post-rename option works in the same way as :rename-keys but it's performed after all other transformations are applied.

The :use-seq option has the effect only if the returned value is a sequential collection having even number of arguments. If it's set then the sequence is changed into a map for further processing (including renaming keys) instead of being put as a value associated with some key.

The :apply-raw option is for performance reasons. Use it with care. It disables checks and most of the transformations and causes wrapper to assume that the resulting structure is either single value, sequential collection or a map. If it's an atomic value or a map, it will change it into sequence ready to be applied as named arguments when calling the next function. If it's a sequence then nothing will be changed.

Defaults for the options described above may be given by passing a map as a first or last argument when calling the comp function. Such a map should not contain :f key.

The comp function returns a function object.

Takes a set of functions that accept named arguments and returns a function
object that is the composition of those functions. The returned function
takes named arguments, applies the rightmost of functions to the arguments,
the next function (right-to-left) to the result, etc.

Each function should return a map or a sequential collection (see :use-seq
switch) that will be used to generate named arguments for the next function
in the execution chain. If a function does not return a map its resulting
value will be assigned to a key of newly created map. The default name of
this key will be :out unless the option :map-output had been used (see the
explanations below).

The returned value of the last called function is not transformed in any way
and there is no need for it to be a map.

Functions can be expressed as function objects or as maps. In the second
case the map must contain :f key with function object assigned to it and may
contain optional, controlling options which are:

- :merge-args   nil (default) or true or a key,
- :map-output   nil (default) or true or a key,
- :rename-keys  nil (default) or a map,
- :post-rename  nil (default) or a map,
- :use-seq      nil (default) or true,
- :apply-raw    nil (default) or true.

The :merge-args option, when is not set to false nor nil, causes function
arguments to be merged with a returned map. If the key is given they all
will be stored under specified key of this map. If the assigned value is set
to true then they will be merged. If two keys are the same the association
from arguments is overwritten by the entry being returned by a function.

The :map-output causes the returned value to be stored under a specified key
of a resulting map. If the option value is set to true then the key name
will be :out.

The :rename-keys option causes keys of a resulting map to be renamed
according to the given map. The transformation will be performed on a
returned value (if it's a map), before any other changes (output mapping or
arguments merging).

The :post-rename option works in the same way as :rename-keys but it's
performed after all other transformations are applied.

The :use-seq option has the effect only if the returned value is a
sequential collection having even number of arguments. If it's set then the
sequence is changed into a map for further processing (including renaming
keys) instead of being put as a value associated with some key.

The :apply-raw option is for performance reasons. Use it with care. It
disables checks and most of the transformations and causes wrapper to assume
that the resulting structure is either single value, sequential collection
or a map. If it's an atomic value or a map, it will change it into sequence
ready to be applied as named arguments when calling the next function. If
it's a sequence then nothing will be changed.

Defaults for the options described above may be given by passing a map as a
first or last argument when calling the comp function. Such a map should not
contain :f key.

The comp function returns a function object.
raw docstring

comp-explainclj

(comp-explain)
(comp-explain f)
(comp-explain f & more)

Works like futils.named/comp but instead of composing function it shows the execution chain represented as a map.

Works like futils.named/comp but instead of composing function it shows the
execution chain represented as a map.
raw docstring

identityclj

(identity & args)

Like clojure.core/identity but works on named arguments. Returns the arguments as a sequence.

Like clojure.core/identity but works on named arguments. Returns the
arguments as a sequence.
raw docstring

nameizecljmacro

(nameize f exp-args)
(nameize f exp-args defaults & more)

Creates a wrapper that passes named arguments as positional arguments. It takes a funtion object (f), a vector S-expression containing names of expected arguments (names – expressed as keywords, symbols, strings or other objects) and an optional map S-expression with default values for named arguments (defaults).

Since version 0.7.0 it accepts multiple arity mappings expressed as pairs consisting of argument name vectors and maps of default values (for all or some of the names).

The order of names in a vector is important. Each name will become a key of named argument which value will be passed to the given function on the same position as in the vector.

If unquoted symbol is given in a vector or in a map, it will be transformed into a keyword of the same name. Use quoted symbols if you want to use symbols as keys of named arguments.

If the &rest special symbol is placed in a vector then the passed value that corresponds to its position will be a map containing all named arguments that weren't handled. If there are none, nil value is passed.

The macro is capable of handling multiple arities. In such case the declared arities (e.g. [:a :b] [:a :b :c]) will be matched against the given named arguments (e.g. {:a 1 :b 2}) by comparing declared argument names to key names. Firstly it will try to match them without considering default values (if any) and in case of no success (when there is no declared arity that can be satisfied by the given arguments) matching is preformed again but with default arguments merged. From the resulting collection of matching arity mappings the one element with the least requirements is chosen (that has the lowest count of declared arguments).

Creates a wrapper that passes named arguments as positional arguments. It
takes a funtion object (f), a vector S-expression containing names of
expected arguments (names – expressed as keywords, symbols, strings or
other objects) and an optional map S-expression with default values for
named arguments (defaults).

Since version 0.7.0 it accepts multiple arity mappings expressed as
pairs consisting of argument name vectors and maps of default values (for
all or some of the names).

The order of names in a vector is important. Each name will become a key
of named argument which value will be passed to the given function on the same
position as in the vector.

If unquoted symbol is given in a vector or in a map, it will be transformed
into a keyword of the same name. Use quoted symbols if you want to use symbols
as keys of named arguments.

If the &rest special symbol is placed in a vector then the passed value that
corresponds to its position will be a map containing all named arguments that
weren't handled. If there are none, nil value is passed.

The macro is capable of handling multiple arities. In such case the declared
arities (e.g. [:a :b] [:a :b :c]) will be matched against the given named
arguments (e.g. {:a 1 :b 2}) by comparing declared argument names to key
names. Firstly it will try to match them without considering default
values (if any) and in case of no success (when there is no declared arity
that can be satisfied by the given arguments) matching is preformed again but
with default arguments merged. From the resulting collection of matching arity
mappings the one element with the least requirements is chosen (that has the
lowest count of declared arguments).
raw docstring

nameize*clj

(nameize* f & arity-pairs)

Creates a wrapper that passes named arguments as positional arguments. It takes a funtion object (f), a vector S-expression containing names of expected arguments (names – expressed as keywords, symbols, strings or other objects) and an optional map S-expression with default values for named arguments (defaults).

Since version 0.7.0 it accepts multiple arity mappings expressed as pairs consisting of argument name vectors and maps of default values (for all or some of the names).

The order of names in a vector is important. Each name will become a key of named argument which value will be passed to the given function on the same position as in the vector.

If unquoted symbol is given in a vector or in a map, it will be transformed into a keyword of the same name. Use quoted symbols if you want to use symbols as keys of named arguments.

If the &rest special symbol is placed in a vector then the passed value that corresponds to its position will be a map containing all named arguments that weren't handled. If there are none, nil value is passed.

The function is capable of handling multiple arities. In such case the declared arities (e.g. [:a :b] [:a :b :c]) will be matched against the given named arguments (e.g. {:a 1 :b 2}) by comparing declared argument names to key names. Firstly it will try to match them without considering default values (if any) and in case of no success (when there is no declared arity that can be satisfied by the given arguments) matching is preformed again but with default arguments merged. From the resulting collection of matching arity mappings the one element with the least requirements is chosen (that has the lowest count of declared arguments).

Creates a wrapper that passes named arguments as positional arguments. It
takes a funtion object (f), a vector S-expression containing names of
expected arguments (names – expressed as keywords, symbols, strings or
other objects) and an optional map S-expression with default values for
named arguments (defaults).

Since version 0.7.0 it accepts multiple arity mappings expressed as
pairs consisting of argument name vectors and maps of default values (for
all or some of the names).

The order of names in a vector is important. Each name will become a key
of named argument which value will be passed to the given function on the same
position as in the vector.

If unquoted symbol is given in a vector or in a map, it will be transformed
into a keyword of the same name. Use quoted symbols if you want to use symbols
as keys of named arguments.

If the &rest special symbol is placed in a vector then the passed value that
corresponds to its position will be a map containing all named arguments that
weren't handled. If there are none, nil value is passed.

The function is capable of handling multiple arities. In such case the declared
arities (e.g. [:a :b] [:a :b :c]) will be matched against the given named
arguments (e.g. {:a 1 :b 2}) by comparing declared argument names to key
names. Firstly it will try to match them without considering default
values (if any) and in case of no success (when there is no declared arity
that can be satisfied by the given arguments) matching is preformed again but
with default arguments merged. From the resulting collection of matching arity
mappings the one element with the least requirements is chosen (that has the
lowest count of declared arguments).
raw docstring

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

× close