Liking cljdoc? Tell your friends :D

fogus.reg

A minimal functional registry system inspired by clojure.spec.alpha.

Provides core registry operations for managing namespaced identifiers. Users maintain their own atoms/maps and the registry functions herein to manage them. A registry is map from namespaced identifiers (keywords or symbols) to arbitrary values, enabling global lookup and reuse of named items.

Important ideas that differentiate registries from raw maps held in atoms:

  • Identifier: Either a keyword or a symbol, preferably qualified.
  • Alias: A registry entry whose value is an identifier that points to another identifier, creating indirection that allows one key to reference another's value.
  • Alias chain: The sequence of identifiers traversed when resolving an alias, showing each indirection step from the initial key to the final non-identifier value.
  • Cycle: Alias chains may have cycles, and this library can detect and annotate them.

Because registries are just maps - use standard Clojure functions for selection/query.

A minimal functional registry system inspired by clojure.spec.alpha.
  
Provides core registry operations for managing namespaced identifiers.
Users maintain their own atoms/maps and the registry functions herein to
manage them. A registry is map from namespaced identifiers (keywords or
symbols) to arbitrary values, enabling global lookup and reuse of named
items.

Important ideas that differentiate registries from raw maps held in
atoms:

- Identifier: Either a keyword or a symbol, preferably qualified.
- Alias: A registry entry whose value is an identifier that points to
another identifier, creating indirection that allows one key to reference
another's value.
- Alias chain: The sequence of identifiers traversed when resolving an
alias, showing each indirection step from the initial key to the final
non-identifier value.
- Cycle: Alias chains may have cycles, and this library can detect and
annotate them.   

Because registries are just maps - use standard Clojure functions for
selection/query.
raw docstring

aliasclj

(alias registry k target)

Register identifier k as an alias to target identifier in registry.

Register identifier k as an alias to target identifier in registry.
raw docstring

alias-chainclj

(alias-chain reg k)

Given registry reg, returns the chain of aliases from k to its final resolved value. An alias chain is a vector showing the resolution chain, or nil if k not found. If the chain has a cycle, then the predicate cyclic? will return true fir it.

Given registry reg, returns the chain of aliases from k to its
final resolved value. An alias chain is a vector showing the resolution
chain, or nil if k not found. If the chain has a cycle, then the predicate
cyclic? will return true fir it.
raw docstring

cyclic?clj

(cyclic? chain)

Given an alias chain, return true if there is a cycle, flase otherwise.

Given an alias chain, return true if there is a cycle, flase otherwise.
raw docstring

lookupclj

(lookup reg k)

Lookup identifier k in registry, following alias chains.

If the value at k is itself an identifier, then lookup recursively looks it up until finding a non-identifier value. This enables indirection, allowing you to register ::foo as ::bar, and resolving ::foo will return whatever ::bar points to.

Returns the resolved item, or nil if k is not found. Attempting to lookup a non-identifier is undefined and likely an error.

Lookup identifier k in registry, following alias chains.

If the value at k is itself an identifier, then lookup recursively looks
it up until finding a non-identifier value. This enables indirection, allowing
you to register ::foo as ::bar, and resolving ::foo will return whatever
::bar points to.

Returns the resolved item, or nil if k is not found. Attempting to lookup
a non-identifier is undefined and likely an error.
raw docstring

lookup!clj

(lookup! registry k)

Lookup identifier k in registry, throwing if not found.

Like lookup, but throws an exception if k cannot be resolved. Useful when a missing registry entry is an error condition. Returns the resolved item.

Lookup identifier k in registry, throwing if not found.

Like lookup, but throws an exception if k cannot be resolved.
Useful when a missing registry entry is an error condition.
Returns the resolved item.
raw docstring

registerclj

(register registry k item)

Register an item under identifier k in registry, returning a new registry. If item is nil, then the mapping for k is removed from the registry.

Register an item under identifier k in registry, returning a new registry.
If item is nil, then the mapping for k is removed from the registry.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close