Encoding Souther-generated values back to Clojure data -- the inverse of souther.decode.
Every generated type has a public encoder() that yields its external representation: a newtype
encodes to its bare underlying value, a record/sum to a map (with nested newtypes already
unwrapped). That is exactly the unwrapping a Clojure boundary wants, so encode runs the
encoder and hands back Clojure data -- no chains of .value / field accessors.
Encoding Souther-generated values back to Clojure data -- the inverse of `souther.decode`. Every generated type has a public `encoder()` that yields its external representation: a newtype encodes to its bare underlying value, a record/sum to a map (with nested newtypes already unwrapped). That is exactly the unwrapping a Clojure boundary wants, so `encode` runs the encoder and hands back Clojure data -- no chains of `.value` / field accessors.
(encode value)Encode a Souther-generated value to Clojure data through its generated encoder(). A newtype
becomes its bare underlying value; a record/sum becomes a keyword-keyed map with nested newtypes
already unwrapped. The inverse of souther.decode/decode.
Encode a Souther-generated `value` to Clojure data through its generated `encoder()`. A newtype becomes its bare underlying value; a record/sum becomes a keyword-keyed map with nested newtypes already unwrapped. The inverse of `souther.decode/decode`.
(unwrap value)The bare value inside a newtype wrapper, via encode. Throws if value is not a single-value
wrapper (its encoded form is a map/list), so a call site reads as a claim that the value is a
newtype.
The bare value inside a newtype wrapper, via `encode`. Throws if `value` is not a single-value wrapper (its encoded form is a map/list), so a call site reads as a claim that the value is a newtype.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |