You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
casegivenShow[FieldType] =>2case _ =>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.
The text was updated successfully, but these errors were encountered:
From a similar test, it appears not to help, and the problem lies in the Scala compiler.
propensive
changed the title
summonInline/summonFrom does not seem to work on field typessummonInline/summonFrom does not work on field types
Jan 8, 2025
One possibility workaround could be to provide a new method, summonPoly, which will summon a specified typeclass corresponding to the particular field type. So instead of writing, summonInline[Show[fieldType]], you could write, summonPoly[Show]. It's not entirely clear whether this would work.
A proper test is required, but it seems like inline summoning does not work inside polymorphic lambdas, e.g. in
The default
case
will always match, even if there areShow
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.The text was updated successfully, but these errors were encountered: