Follow-up to #51 (typed-builder).
Made.Product.fromTuple covers the typed builder use case. Magnolia-style construct
may also be valuable for derivation typeclass scenarios where a per-field function
materializes values.
Proposal (shape TBD)
One possible signature — exact shape not decided:
def construct(f: [e <: MadeFieldElem] => (elem: e) => elem.Type): Type
Alternatives worth considering:
- Magnolia-style homogeneous
[R](f: MadeFieldElem => R): T with cast
- Rank-2 trait
trait Constructor[T] { def apply[X](elem: MadeFieldElem { type Type = X }): X }
- Typeclass-aware variant requiring
F[t] summon per field
Implementation notes (if polymorphic-function shape)
- Polymorphic function application inside macro quotes
- Macro-time unrolling of
Elems tuple to preserve per-field path-dependent typing at each f($e) call site
- Builds on
fromTuple — generated body roughly m.fromProduct((f(e0), f(e1), ...))
Why deferred
Requires polymorphic function application inside quotes plus macro-side tuple unrolling — more
involved than fromTuple. Deferred to keep #51 minimal. Non-breaking to add later.
Concrete consumer use cases would help nail down the exact API shape.
Follow-up to #51 (typed-builder).
Made.Product.fromTuplecovers the typed builder use case. Magnolia-styleconstructmay also be valuable for derivation typeclass scenarios where a per-field function
materializes values.
Proposal (shape TBD)
One possible signature — exact shape not decided:
Alternatives worth considering:
[R](f: MadeFieldElem => R): Twith casttrait Constructor[T] { def apply[X](elem: MadeFieldElem { type Type = X }): X }F[t]summon per fieldImplementation notes (if polymorphic-function shape)
Elemstuple to preserve per-field path-dependent typing at eachf($e)call sitefromTuple— generated body roughlym.fromProduct((f(e0), f(e1), ...))Why deferred
Requires polymorphic function application inside quotes plus macro-side tuple unrolling — more
involved than
fromTuple. Deferred to keep #51 minimal. Non-breaking to add later.Concrete consumer use cases would help nail down the exact API shape.