Skip to content
This repository has been archived by the owner on May 7, 2019. It is now read-only.

Decoder creation from Try #64

Open
andyscott opened this issue Jul 7, 2017 · 0 comments
Open

Decoder creation from Try #64

andyscott opened this issue Jul 7, 2017 · 0 comments

Comments

@andyscott
Copy link
Collaborator

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)))
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant