Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

summonInline/summonFrom does not seem to work on field types #20

Open
propensive opened this issue Jun 10, 2024 · 0 comments
Open

summonInline/summonFrom does not seem to work on field types #20

propensive opened this issue Jun 10, 2024 · 0 comments
Assignees
Labels
api Relates to the API design enhancement An improvement to existing functionality

Comments

@propensive
Copy link
Owner

propensive commented Jun 10, 2024

A proper test is required, but it seems like inline summoning does not work inside polymorphic lambdas, e.g. in

fields(value): [FieldType] =>
  field =>
    summonFrom:
      case given Show[FieldType] => 2
      case _                     => 4

The default case will always match, even if there are Show instances available for each field type.

I think this is a limitation of Scala, because even after inlining, FieldType is a abstract type parameter, and there's never a typeclass instance in-scope for exactly that type parameter.

We could mitigate this by first resolving an IArray of typeclass instances for each field type, and then accessing it by index (which is available in the polymorphic lambda.

@propensive propensive self-assigned this Jun 10, 2024
@propensive propensive added enhancement An improvement to existing functionality api Relates to the API design labels Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Relates to the API design enhancement An improvement to existing functionality
Projects
Status: Todo
Development

No branches or pull requests

1 participant