diff --git a/src/lib/Witch/TryCastException.hs b/src/lib/Witch/TryCastException.hs index 9853736..e91db6e 100644 --- a/src/lib/Witch/TryCastException.hs +++ b/src/lib/Witch/TryCastException.hs @@ -8,18 +8,21 @@ import qualified Data.Typeable as Typeable newtype TryCastException source target = TryCastException source - deriving (Eq, Show) + deriving Eq instance ( Show source , Typeable.Typeable source , Typeable.Typeable target - ) => Exception.Exception (TryCastException source target) where - displayException (TryCastException x) = mconcat - [ "TryCastException: failed to cast value " - , show x - , " from type " - , show $ Typeable.typeOf x - , " into type " - , show $ Typeable.typeRep (Proxy.Proxy :: Proxy.Proxy target) - ] + ) => Show (TryCastException source target) where + showsPrec d (TryCastException x) = showParen (d > 10) + $ showString "TryCastException {- " + . shows (Typeable.typeRep (Proxy.Proxy :: Proxy.Proxy (source -> target))) + . showString " -} " + . showsPrec 11 x + +instance + ( Show source + , Typeable.Typeable source + , Typeable.Typeable target + ) => Exception.Exception (TryCastException source target)