Discussion: add more idiomatic versions of catchJust and/or handleJust

Bardur Arantsson spam at scientician.net
Thu Jul 14 20:24:50 UTC 2016


On 07/14/2016 08:06 PM, Oleg Grenrus wrote:
> Maybe pointing out the obvious, but when used with lens, catchJust approach is handy:
> 
> — | here catchJust is from `exceptions` though
> catching :: MonadCatch m => Getting (First a) SomeException a -> m r -> (a -> m r) -> m r
> catching l = catchJust (preview l)
> 
> http://hackage.haskell.org/package/lens-4.14/docs/src/Control.Exception.Lens.html#catching

lens is not a very appealing to have as a dependency if one is oneself
writing a library for others to consume. (Because of the huge set of
dependencies.)




More information about the Libraries mailing list