cats
cats copied to clipboard
MonadError missing a raiseWhen method
Is there a reason for IO#raiseWhen being omitted from MonadError
?
MonadError has ensure, but if [A]
is Unit
, this is more verbose compared to raiseWhen
.
For example using raiseWhen
:
IO.raiseWhen(condition)(expression)
Versus using ensure
:
MonadThrow[F].unit.ensure(exception)(_ => condition)
If adding this method to MonadError
is a welcome change, I'd like to make a PR for it!