Skip to content

[data] records more than 22 AsFields (#1006) - #1013

Merged
fwbrasil merged 3 commits into
getkyo:mainfrom
road21:1006-kyo-records-more-than-22-as-fields
Jan 14, 2025
Merged

fwbrasil merged 3 commits into
getkyo:mainfrom
road21:1006-kyo-records-more-than-22-as-fields

Conversation

@road21

@road21 road21 commented Jan 14, 2025

Copy link
Copy Markdown
Contributor

I haven't found a way to avoid macro (intersection types don't play well with implicits). So I have created typeclass FieldsLike (evidence) that splits Fields type into tuple of ~ types, and then derives instance for every tuple member.

This typeclass FieldsLike could potentially be used for other features like removing fields by keys.

All(f.fields + a)
end All

given [A](using ev: FieldsLike[A], a: All[ev.T]): AsFields[A] = a.fields

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting pattern! I hadn't considered transforming the intersection to tuples first

@fwbrasil

Copy link
Copy Markdown
Collaborator

thank you @road21!

@fwbrasil
fwbrasil merged commit a8a8011 into getkyo:main Jan 14, 2025
fwbrasil added a commit that referenced this pull request Jan 17, 2025
…idence (#1021)

This PR generalizes the approach introduced by @road21 in
#1013 and introduces `CanEqual` for
`Record`. I gave a shot at providing `Render` with but couldn't make it
work properly.

I'm planning to try `TypeSet` to resolve the inference issues we have
with `Boundary`. We currently have to use an `inline` [method
indirection](https://github.com/getkyo/kyo/blob/5674fab6a54feae3d8936182c18f73082910810f/kyo-core/shared/src/main/scala/kyo/Async.scala#L76)
for boundaries to infer correctly.

---------

Co-authored-by: Adam Hearn <[email protected]>
Co-authored-by: Aleksey Troitskiy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants