Rohde Fischer
10/13/2024, 2:50 PMdata 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)