dev.constructive.eo.chimney
Members list
Type members
Classlikes
Constructors that turn chimney's derived transformations into eo optics. Each one summons (or, for chimney's Iso / Codec, derives) the chimney value and hands it to the matching .toX extension in the chimney package — use those directly when you already hold a hand-configured chimney value (Transformer.define[…].withFieldRenamed(…).buildTransformer).
Constructors that turn chimney's derived transformations into eo optics. Each one summons (or, for chimney's Iso / Codec, derives) the chimney value and hands it to the matching .toX extension in the chimney package — use those directly when you already hold a hand-configured chimney value (Transformer.define[…].withFieldRenamed(…).buildTransformer).
Constructors, not givens: several lawful optics can share an (S, A) pair, so the caller declares the one it wants (the cats-eo doctrine for every bridge).
| chimney | eo optic | writes? |
|---|---|---|
Transformer[S, T] |
Getter[S, T] |
no |
Iso[A, B] |
Iso[A, B] (BijectionIso) |
yes |
Codec[Domain, Dto] |
Prism from Dto to Domain |
yes |
PartialTransformer[S, T] |
ForgetFold[S, PartialResult, T] (keeps the errors) |
no |
Patcher[A, P] |
Modify[A, A, Unit, P] (replace(p)) |
yes |
Attributes
- Source
- Chimney.scala
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Chimney.type
Attributes
- Source
- PartialResult.scala
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
PartialResult.type
Types
chimney's partial.Result[A] as the container of a optics.ForgetFold: what Chimney.resultFold and .toResultFold() read into.
chimney's partial.Result[A] as the container of a optics.ForgetFold: what Chimney.resultFold and .toResultFold() read into.
An opaque alias, not a new type — the runtime value is chimney's own partial.Result — so its companion can carry the cats instances a fold needs and core's ReadCompose finds them in implicit scope with no import (the public cats instances for partial.Result belong to chimney-cats; these are scoped to this alias). With them, a ForgetFold[S, PartialResult, A] keeps chimney's errors through composition:
andThena lens / iso /Gettermaps the result (Functor);andThena prism / optional /AffineFoldmaps it too, an inner miss becoming chimney's "empty value" error (FunctorFilter.mapFilter, viapartial.Result.fromEmpty);andThenanotherForgetFold[A, PartialResult, C]flat-maps, so both sides' errors surface (Monad).
Multi-focus inners (Traversal, Fold over a collection) have no single result to keep and fall back to core's List fold.
Attributes
- Source
- PartialResult.scala
Extensions
Extensions
This codec as a prism from Dto to Domain: getOption decodes, reverseGet encodes. See Chimney.prism.
This codec as a prism from Dto to Domain: getOption decodes, reverseGet encodes. See Chimney.prism.
Attributes
- Source
- package.scala
The error-free view: a plain optics.PickFold with the same hits.
The error-free view: a plain optics.PickFold with the same hits.
Attributes
- Source
- PartialResult.scala
The focus or the errors, as an Either — result(s).asEither.
The focus, dropping the errors.
The focus or chimney's errors, with their field paths.
This chimney Iso as an eo Iso: get = first, reverseGet = second. See Chimney.iso.
This chimney Iso as an eo Iso: get = first, reverseGet = second. See Chimney.iso.
Attributes
- Source
- package.scala
Patch the focus: o.modify(a => patcher.patch(a, p)). eo finds the part, chimney merges the patch's fields into it — lens[Order](_.customer).patch(CustomerPatch(email = "…"))(order). A miss (Prism / Optional) passes the S through untouched; a Traversal patches every focus. chimney derives the Patcher when none is in scope.
Patch the focus: o.modify(a => patcher.patch(a, p)). eo finds the part, chimney merges the patch's fields into it — lens[Order](_.customer).patch(CustomerPatch(email = "…"))(order). A miss (Prism / Optional) passes the S through untouched; a Traversal patches every focus. chimney derives the Patcher when none is in scope.
Attributes
- Source
- package.scala
Change the type you write at the focus: the new optic accepts a C and runs chimney's Transformer[C, B] to turn it into the B this optic writes back. Reads, the source and the result are unchanged — Optic[S, T, A, C] — so the focus reads as an A and is written as a C: lens[User](_.address).transformFocus[AddressView].replace(view)(user) writes a view where the lens expects an Address. Works on monomorphic optics (eo-generics' lenses); on a polymorphic one (Traversal.pEach[List, RawPrice, Price]), transformFocus[RawPrice] lets an edit of the RawPrice it reads be written back as a Price (.modify(r => RawPrice(r.cents * 2)) reprices and retypes in one write). The write-side counterpart of transformImage, which changes T; together they give Optic[S, U, A, C]. chimney derives the Transformer when none is in scope.
Change the type you write at the focus: the new optic accepts a C and runs chimney's Transformer[C, B] to turn it into the B this optic writes back. Reads, the source and the result are unchanged — Optic[S, T, A, C] — so the focus reads as an A and is written as a C: lens[User](_.address).transformFocus[AddressView].replace(view)(user) writes a view where the lens expects an Address. Works on monomorphic optics (eo-generics' lenses); on a polymorphic one (Traversal.pEach[List, RawPrice, Price]), transformFocus[RawPrice] lets an edit of the RawPrice it reads be written back as a Price (.modify(r => RawPrice(r.cents * 2)) reprices and retypes in one write). The write-side counterpart of transformImage, which changes T; together they give Optic[S, U, A, C]. chimney derives the Transformer when none is in scope.
A generic Optic, like Optic.innerProfunctor.lmap — but to is the original optic's own, so reads don't pay a carrier map they never use; only from maps the written Cs.
Attributes
- Source
- package.scala
transformFocus for a PartialTransformer[C, B]: write a C, and get back the new T or the errors of every written C that didn't convert (all of them — errors accumulate across a Traversal's foci) — Optic[S, partial.Result[T], A, C]. The error paths are relative to each focus: chimney does not know where the optic pointed.
transformFocus for a PartialTransformer[C, B]: write a C, and get back the new T or the errors of every written C that didn't convert (all of them — errors accumulate across a Traversal's foci) — Optic[S, partial.Result[T], A, C]. The error paths are relative to each focus: chimney does not know where the optic pointed.
One pass, no per-focus partial.Result plumbing: the carrier's map converts every written C to B | Null — a failing one records its errors on the side and leaves null — and only if none failed does this optic's from rebuild the T, at which point every slot holds a real B. On any failure the mapped carrier is dropped and the errors returned: the underlying optic's write path never sees a null. The ForgetfulTraverse gate (otherwise unused) keeps this to carriers whose map runs eagerly, so every error is in before from is decided.
Attributes
- Source
- package.scala
Change the result type: run chimney's Transformer[T, U] on whatever the optic writes back, turning its S => T side into S => U — the result-side counterpart of transformFocus. Every write lands in U: lens[User](_.name).transformImage[UserView].modify(_.trim)(user) edits a field and hands back the view. A miss (Prism / Optional) still produces a U — the untouched T, transformed. The focus side (S, A, B) is unchanged, so reads are the original optic's. chimney derives the Transformer when none is in scope.
Change the result type: run chimney's Transformer[T, U] on whatever the optic writes back, turning its S => T side into S => U — the result-side counterpart of transformFocus. Every write lands in U: lens[User](_.name).transformImage[UserView].modify(_.trim)(user) edits a field and hands back the view. A miss (Prism / Optional) still produces a U — the untouched T, transformed. The focus side (S, A, B) is unchanged, so reads are the original optic's. chimney derives the Transformer when none is in scope.
Core's Optic.outerProfunctor.rmap with a chimney transformer: the result is a generic Optic (the concrete class's fused overloads don't survive the remap).
Attributes
- Source
- package.scala
transformImage for a PartialTransformer[T, U]: every write hands back the U or the errors of turning the written T into one — "edit the DTO, then validate it into the domain".
transformImage for a PartialTransformer[T, U]: every write hands back the U or the errors of turning the written T into one — "edit the DTO, then validate it into the domain".
Attributes
- Source
- package.scala
This patcher as a write-only optic: replace(patch) patches the A. See Chimney.patching.
This patcher as a write-only optic: replace(patch) patches the A. See Chimney.patching.
Attributes
- Source
- package.scala
This partial transformer as a fold into its result — a ForgetFold[S, PartialResult, T] that keeps chimney's errors through composition (see PartialResult). failFast = true stops at the first error, as chimney's transformFailFast does. See Chimney.resultFold.
This partial transformer as a fold into its result — a ForgetFold[S, PartialResult, T] that keeps chimney's errors through composition (see PartialResult). failFast = true stops at the first error, as chimney's transformFailFast does. See Chimney.resultFold.
Attributes
- Source
- package.scala
This transformer as a read: get(s) = t.transform(s). See Chimney.getter.
This transformer as a read: get(s) = t.transform(s). See Chimney.getter.
Attributes
- Source
- package.scala