never executed always true always false
    1 {-|
    2 Module: Flaw.Exception
    3 Description: Useful things for exceptions.
    4 License: MIT
    5 -}
    6 
    7 {-# LANGUAGE DeriveDataTypeable, GADTs, StandaloneDeriving #-}
    8 
    9 module Flaw.Exception
   10   ( DescribeException(..)
   11   , describeException
   12   ) where
   13 
   14 import Control.Exception
   15 import Data.Typeable
   16 
   17 -- | Exception data wrapping exception with textual description.
   18 data DescribeException where
   19   DescribeFirstException :: Show a => !a -> DescribeException
   20   DescribeException :: Show a => !a -> !SomeException -> DescribeException
   21 deriving instance Show DescribeException
   22 deriving instance Typeable DescribeException
   23 
   24 instance Exception DescribeException
   25 
   26 -- | Wrap possible exceptions with textual description.
   27 {-# INLINE describeException #-}
   28 describeException :: Show msg => msg -> IO a -> IO a
   29 describeException message work = catch work $ \e -> throwIO $ DescribeException message e