have anyone found a good way to deal with kotlinx.serialization and having proper typings? I.e., say I have
data class Foo
, which have a nicely typed parser
fun parseFoo(text: String): Either<NonEmptyList<FooParseError>, Foo>
, I'd like to serialize an instance of
Foo
directly, but when I deserialize, It would be nice to get the either. So I'm basically looking for something giving the pattern:
object FooSerializer : KNiceSerializer {
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("Foo", PrimitiveKind.STRING)
override fun serialize(
encoder: Encoder,
value: Foo,
) { TODO() }
override fun deserialize(decoder: Decoder): Either<NonEmptyList<FooParseError>, Foo>, { TODO() }
}
does this exist? If not is there a good way to do this? (Is it even possible, I'm assuming
FooParseError
might cause problems, even if such an interface was made)