Could be arrow meta also used to resolve instance ...
# arrow-meta
d
Could be arrow meta also used to resolve instance of Kotlinx.Serialization (some context in comments) at compile time?
To pass from a given T to its String representation you could use this method
You have to pass both, the instance T and a Serializer for that given T
If you don’t want to always pass the serializer you could use
KClass<T>.serializer
and is not recommended
s
It's possible with a higher abstraction such as
@Proof
that @raulraja already build and showed in several talks. Since all you want to do is proof that those implementations exist, and rely on it.
The passing technique they're using in KotlinX Serialisation is exactly the same as passing around typeclass instances as we currently do in Arrow. So both can solved in the same way. A concrete compiler plugin (similar to kapt for Moshi), typeclasses, proofs, ..
d
🙏
It this way I’ll have both simpler APIs and compile time safety, right?
s
Yes, it would allow you to define 1 serializer per type and it would result in a compilation error if there is ambiguity or an implementation missing.
d
Thanks