Liking cljdoc? Tell your friends :D

clj-foundation.patterns

Patterns DRY up code and provide a vocabulary for conversation. This package helps Clojure deal with types from Java, makes it easier to build maps that represent abstract data types, provides functional programming utilities, and adds a Nothing type that behaves as an identity value for maps, sequences, and strings under their various concatination operations. (For Category theorists, it's a monadic zero for these types under concatination and mapcat.) It also provides Nothing constants for cases where Nothing means 'error', 'no result', or simply 'use default settings'.

Patterns DRY up code and provide a vocabulary for conversation.  This package helps Clojure deal with
types from Java, makes it easier to build maps that represent abstract data types, provides functional
programming utilities, and adds a Nothing type that behaves as an identity value for maps, sequences,
and strings under their various concatination operations.  (For Category theorists, it's a monadic zero
for these types under concatination and mapcat.)  It also provides Nothing constants for cases where
Nothing means 'error', 'no result', or simply 'use default settings'.
raw docstring

arityclj

(arity f)

Returns the maximum parameter count of each invoke method found by reflection on the input instance. The returned value can be then interpreted as the arity of the input function. The count does NOT detect variadic functions.

Returns the maximum parameter count of each invoke method found by reflection
on the input instance. The returned value can be then interpreted as the arity
of the input function. The count does NOT detect variadic functions.
sourceraw docstring

def-singleton-fncljmacro

(def-singleton-fn name & body)

Define a function whose return value is initilized once by executing body and that returns that same value on every subsequent call. A Clojure implementation of the Singleton pattern.

Define a function whose return value is initilized once by executing body and that returns
that same value on every subsequent call.  A Clojure implementation of the Singleton pattern.
sourceraw docstring

fcljmacro

(f & all)

A "where" form for anonymous functions. e.g.:

  • If the body of the function is a single function call, the parens may be omitted. (f x y => + x y) (f x y & more => apply + x y more)

  • If more statements are needed, they are wrapped in an implicit (do ...) (f => (log/warning "She's about to blow!") (self-destruct))

A "where" form for anonymous functions.  e.g.:

* If the body of the function is a single function call, the parens may be omitted.
  (f x y => + x y)
  (f x y & more => apply + x y more)

* If more statements are needed, they are wrapped in an implicit (do ...)
  (f => (log/warning "She's about to blow!")
        (self-destruct))
sourceraw docstring

get-class-nameclj

(get-class-name clazz)

Inputs: [clazz :- Class] Returns: s/Str

Returns the unqualified class name for the specified Class

Inputs: [clazz :- Class]
Returns: s/Str

Returns the unqualified class name for the specified Class
sourceraw docstring

get-packageclj

(get-package clazz)

Inputs: [clazz :- Class] Returns: s/Str

Returns the package name for the specified Class

Inputs: [clazz :- Class]
Returns: s/Str

Returns the package name for the specified Class
sourceraw docstring

KeywordValuePairsclj

A schema for keyword-value pairs. Currently unsupported by Schema so defining once here so that once support lands, there is only one place to change to enforce it everywhere.

A schema for keyword-value pairs.  Currently unsupported by Schema so defining once here so that once support lands,
there is only one place to change to enforce it everywhere.
sourceraw docstring

let-mapcljmacro

(let-map var-exprs & body)

A version of let that returns its local variables in a map. If a result is computed in the body, and that result is another map, let-map returns the result of conj-ing the result map into the let expression map. Otherwise it returns a vector containing the let expression map followed by the result.

A version of let that returns its local variables in a map.
If a result is computed in the body, and that result is another map,
let-map returns the result of conj-ing the result map into the let
expression map.  Otherwise it returns a vector containing the let
expression  map followed by the result.
sourceraw docstring

letfn-mapcljmacro

(letfn-map fn-exprs & body)

A version of letfn that returns its functions in a map. If a result is computed in the body, and that result is another map, fn-map returns the result of conj-ing the result map into the function map. Otherwise it returns a vector containing the function map followed by the result.

A version of letfn that returns its functions in a map.
If a result is computed in the body, and that result is another map,
fn-map returns the result of conj-ing the result map into the function
map.  Otherwise it returns a vector containing the function map
followed by the result.
sourceraw docstring

no-resultclj

(no-result string-value reason)

Inputs: [string-value :- s/Str reason :- s/Any] Returns: Nothing

Create custom Nothingness with a specified (.toString n) and (.why n) value.

Inputs: [string-value :- s/Str reason :- s/Any]
Returns: Nothing

Create custom Nothingness with a specified (.toString n) and (.why n) value.
sourceraw docstring

NO-RESULT-ERRORclj

An instance of Nothing intended for use as a generic error result. It is a separate instance from 'nothing' because returning 'nothing' might not be an error. This value is useful for functions used within map / mapcat / filter (etc...) chains where it is useful to have an error value that behaves like the identity value for a collection.

However, unlike the nothing value, in a string context, NO-RESULT-ERROR returns an error message.

NO-RESULT-ERROR is treated as a failure by the failure? multimethod in the errors package.

An instance of Nothing intended for use as a generic error result.  It is a separate instance
from 'nothing' because returning 'nothing' might not be an error.  This value is useful for functions
used within map / mapcat / filter (etc...) chains where it is useful to have an error value that
behaves like the identity value for a collection.

However, unlike the nothing value, in a string context, NO-RESULT-ERROR returns an error message.

NO-RESULT-ERROR is treated as a failure by the failure? multimethod in the errors package.
sourceraw docstring

nothingclj

Nothing is the value to use when there is nothing to pass or return. Nothing acts like an empty map in a collection context and like an empty string in a string context.

This has the following implications:

  • You can use it as a result in mapcat when you want nothing appended to the output collection.
  • You can cons a value into nothing, resulting in a seq.
  • You can assoc values into a nothing, resulting in a map.
  • You can conj vector pairs into a nothing, resulting in a map.
  • You can concatinate it with other strings using the str function, adding nothing to the other strings.
Nothing is the value to use when there is nothing to pass or return.  Nothing acts like an
empty map in a collection context and like an empty string in a string context.

This has the following implications:

* You can use it as a result in mapcat when you want nothing appended to the output collection.
* You can cons a value into nothing, resulting in a seq.
* You can assoc values into a nothing, resulting in a map.
* You can conj vector pairs into a nothing, resulting in a map.
* You can concatinate it with other strings using the str function, adding nothing to the other strings.
sourceraw docstring

Nothing!clj

(Nothing!)

Inputs: [] Returns: Class

Return the Nothing type (mainly for use in Schemas)

Inputs: []
Returns: Class

Return the Nothing type (mainly for use in Schemas)
sourceraw docstring

something?clj

(something? value)

Inputs: [value :- s/Any] Returns: s/Any

Returns value if value is not nothing ; else returns nil.

Inputs: [value :- s/Any]
Returns: s/Any

Returns value if value is not nothing ; else returns nil.
sourceraw docstring

typesclj

(types & schemas)

Returns a schema that matches the listed surface types only (e.g.: primitive or collection types but not contents). Only designed for schemas that are (instance? java.lang.Class).

Returns a schema that matches the listed surface types only (e.g.: primitive or collection types but
not contents).  Only designed for schemas that are (instance? java.lang.Class).
sourceraw docstring

use-defaultsclj

A synonmym for nothing for use in parameter lists when passing nothing really means for the function to use default values.

A synonmym for nothing for use in parameter lists when passing nothing really means for the
function to use default values.
sourceraw docstring

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

× close