case-classy
case-classy copied to clipboard
Decoder creation from Try
It would be useful to be able to create decoders directly from A => Try[B]
. The error can be directly turned into the underlying error wrapper.
For example, for monix-kafka
:
implicit val decodeKafkaProducerConfig: ConfigDecoder[KafkaProducerConfig] =
Decoder.instance(c => Try(KafkaProducerConfig(c)).toEither.leftMap(DecodeError.Underlying(_)))
this ideally could just be written as:
implicit val decodeKafkaProducerConfig: ConfigDecoder[KafkaProducerConfig] =
Decoder.instance(c => Try(KafkaProducerConfig(c)))