Improve documentation around try cast exceptions

This commit is contained in:
Taylor Fausak 2021-04-23 13:37:26 +00:00 committed by GitHub
parent feb1465a4f
commit 3da265dbf3
2 changed files with 10 additions and 2 deletions

View File

@ -1076,8 +1076,12 @@ instance Cast.Cast LazyText.Text LazyByteString.ByteString where
-- TryCastException
instance Cast.Cast (TryCastException.TryCastException s t0) (TryCastException.TryCastException s t1)
-- | Uses @coerce@.
instance Cast.Cast
(TryCastException.TryCastException s u)
(TryCastException.TryCastException s t)
-- | Uses 'show'.
instance
( Show s
, Typeable.Typeable s
@ -1085,6 +1089,7 @@ instance
) => Cast.Cast (TryCastException.TryCastException s t) String where
cast = show
-- | Converts via 'String'.
instance
( Show s
, Typeable.Typeable s
@ -1092,6 +1097,7 @@ instance
) => Cast.Cast (TryCastException.TryCastException s t) Text.Text where
cast = Utility.via @String
-- | Converts via 'String'.
instance
( Show s
, Typeable.Typeable s

View File

@ -8,7 +8,9 @@ import qualified Data.Typeable as Typeable
-- | This exception is thrown when a @TryCast@ conversion fails. It has the
-- original @source@ value that caused the failure and it knows the @target@
-- type it was trying to convert into.
-- type it was trying to convert into. It also has an optional
-- 'Exception.SomeException' for communicating what went wrong while
-- converting.
data TryCastException source target = TryCastException
source
(Maybe Exception.SomeException)