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.
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.