This file provides guidance to WARP (warp.dev) when working with code in this repository.
fun-map is a Clojure/ClojureScript library that provides a map data structure where values are automatically unwrapped when accessed. It supports lazy evaluation, dependency injection between map values, and lifecycle management.
# Run tests in watch mode (auto-reload on changes)
clj -M:dev:test --watch
# Run all tests once (CLJ + CLJS)
clj -T:build tests
# Run Clojure tests only
clj -M:dev:test
# Run ClojureScript tests only
clj -M:dev:cljs-test
# Build JAR
clj -T:build ci
# Deploy to Clojars
clj -T:build deploy
# Copy clj-kondo config to local dev
clj -T:build copy-clj-kondo-config-
Value Wrappers (
wrapper.cljc): ProtocolValueWrapperdefines how values are unwrapped. Implementations include:FunctionWrapper- wraps a function that receives the map and keyCachedWrapper- caches results with optional focus function for invalidationTracedWrapper- adds tracing/logging capability
-
DelegatedMap (
core.cljc): The main map implementation that:- Delegates to an underlying map
- Applies
fn-entrytransformation on access to unwrap values - Implements full Clojure map interfaces for both CLJ and CLJS
-
Macros (
fun_map.cljc):fw- Creates function wrappers with full destructuring and options (:focus,:trace,:par?,:wrappers)fnk- Shortcut forfwthat auto-focuses on declared keys
src/robertluo/fun_map.cljc- Public API:fun-map,fw,fnk,life-cycle-map,closeable,halt!src/robertluo/fun_map/core.cljc-DelegatedMaptype with CLJ/CLJS implementationssrc/robertluo/fun_map/wrapper.cljc-ValueWrapperprotocol and wrapper typessrc/robertluo/fun_map/helper.cljc- Macro helpers forfw/fnkexpansion
Tests use kaocha with cloverage. Test files mirror source structure in test/.
See doc/improvements.adoc for a tracked list of potential improvements.
Missing keys produce cryptic errors- FIXED: now throws helpfulex-infowith contextCircular deps cause StackOverflowError- FIXED: now detects cycles and reports the path- Plain maps inside fun-maps don't unwrap - use nested fun-maps if you need nested unwrapping
- Iteration realizes all values -
keys,vals,seqtrigger all computations select-keys/intoreturn plain maps - wrappers are lost:keep-ref true+fnk-fnkreceives atoms, not values; usefwwith explicit@in focusupdateon computed key - replacesfnkwith the updated value