Michael Snoyman <michael@snoyman.com> wrote:I think there is no one right approach. However, if you add such a
> shouldBeCaught :: SomeException -> Bool
>
> One first stab at such a function would be to return `False` for
> AsyncException and Timeout, and `True` for everything else, but I'm
> not convinced that this is sufficient. Are there any thoughts on the
> right approach to take here?
function to the exception library, it really belongs into the Exception
type class with the following type:
shouldBeCaught :: (Exception e) => e -> Bool
However, a better approach is to have exception tags. In most cases you
don't want to catch killThread's or timeout's exception, but you do want
to catch all error exceptions:
data Tag = Error | Abort | TryAgain | {- ... -} | Other String
deriving (Data, Eq, Ord, Read, Show, Typeable)
instance IsString Tag where
fromString t = Other t
This could then manifest in the following two functions in the Exception
type class:
hasTag :: (Exception e) => Tag -> e -> Bool
tagsOf :: (Exception e) => e -> [Tag]
Then exception catchers (functions that risk swallowing important
exceptions) could filter by type and tag.
Greets,
Ertugrul
--
Not to be or to be and (not to be or to be and (not to be or to be and
(not to be or to be and ... that is the list monad.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe