Functor/Monad instances for ConfigResult
valenterry opened this issue · 4 comments
Any reason not to have instances for functor/monad etc. for ConfigResult[F, ?]
as long as these instances exist for F
? Would be nice to be able to use mapN
instead of loadConfig
- or use for
comprehensions if the context type allows it.
loadConfig
is essentially mapN
if we swap Either
with Validated
. The reason it exists is because the core module is dependency-free, meaning we can't rely on cats. What also might prevent this from working nicely is that often ConfigResult
is not returned, but a different type extending ConfigResult
, e.g. ConfigValue
. There's no reason why we can't write these instances in the cats module though. I'd happily accept a pull request. :)
👍 let me make a PR for that - I will do it for the (hardcoded) Either
for now.
@vlovgr do you think it makes sense in general to use (or allow) for a Validated
type like in cats? In the end, the Either[ConfigErrors, ?]
essentially does look very similar already.
Thanks! Yes, there is a case for it if you want to use the mapN
syntax in cats.
Ciris 1.x (preview on the 1.x branch) will be based on cats and cats-effect and will provide FlatMap
for ConfigValue
, allowing flatMap
and mapN
, as well as a NonEmptyParallel
instance for parMapN
(which matches the behaviour of loadConfig
in 0.x).