on master help sign in
Mark encoding error functions/types as deprecated (gh-112)
364c7c7Bryan O'Sullivan
Data/Text/Encoding/Error.hs+4
@@ -66,6 +66,7 @@ type OnError a b = String -> Maybe a -> Maybe b
66type OnDecodeError = OnError Word8 Char
66type OnDecodeError = OnError Word8 Char
67
67
68-- | A handler for an encoding error.
68-- | A handler for an encoding error.
69+{-# DEPRECATED OnEncodeError "This exception is never used in practice, and will be removed." #-}
69type OnEncodeError = OnError Char Word8
70type OnEncodeError = OnError Char Word8
70
71
71-- | An exception type for representing Unicode encoding errors.
72-- | An exception type for representing Unicode encoding errors.
@@ -78,6 +79,8 @@ data UnicodeException =
78 -- under the given encoding, or ran out of input in mid-encode.
79 -- under the given encoding, or ran out of input in mid-encode.
79 deriving (Eq, Typeable)
80 deriving (Eq, Typeable)
80
81
82+{-# DEPRECATED EncodeError "This constructor is never used, and will be removed." #-}
83+
81showUnicodeException :: UnicodeException -> String
84showUnicodeException :: UnicodeException -> String
82showUnicodeException (DecodeError desc (Just w))
85showUnicodeException (DecodeError desc (Just w))
83 = "Cannot decode byte '\\x" ++ showHex w ("': " ++ desc)
86 = "Cannot decode byte '\\x" ++ showHex w ("': " ++ desc)
@@ -107,6 +110,7 @@ lenientDecode :: OnDecodeError
107lenientDecode _ _ = Just '\xfffd'
110lenientDecode _ _ = Just '\xfffd'
108
111
109-- | Throw a 'UnicodeException' if encoding fails.
112-- | Throw a 'UnicodeException' if encoding fails.
113+{-# DEPRECATED strictEncode "This function always throws an exception, and will be removed." #-}
110strictEncode :: OnEncodeError
114strictEncode :: OnEncodeError
111strictEncode desc c = throw (EncodeError desc c)
115strictEncode desc c = throw (EncodeError desc c)
112
116