-
Notifications
You must be signed in to change notification settings - Fork 125
Open
Description
The current codec implementations in zio-blocks use a centralized recursive derivation approach. This approach calls a private helper method named deriveCodec in each derive* method, and then recursively traverses the tree to derive the type class.
This approach should be refactored to use the idiomatic implicit-based pattern that the zio-blocks derivation was designed for, in which each derive* method uses contextual data provided via implicit parameters to derive instances or get bindings of its contained components, using F and D.
Current State
The existing codec implementations follow the centralized recursive pattern:
override def deriveRecord[F[_, _], A](...): Lazy[Codec[A]] = Lazy {
deriveCodec(new Reflect.Record(...))
}
private def deriveCodec[A](reflect: Reflect[Binding, A]): Codec[A] = {
// Centralized pattern matching for all types
// Manual ThreadLocal cache with placeholder pattern
// Direct recursive calls to deriveCodec
}Proposed Change
Migrate to the implicit-based approach, like this:
override def deriveRecord[F[_, _], A](
fields: Schema.Fields[F, A],
...
)(implicit F: HasBinding[F], D: HasInstance[F]): Lazy[Codec[A]] = Lazy {
val fieldCodecs = fields.map { field =>
(field.name, D.instance(field.value.metadata))
}
// Create Codec instance using fieldCodecs
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels