on master help sign in
Replace types with their more descriptive synonyms

--HG-- extra : convert_revision : aef0a6c4594869f6d37b367d2c73bf4f133bef75

commit5cf629c02e3c4951aaf5ec4fc422190fd08a0d3b authorBryan O'Sullivan <bos@serpentine.com> dateWed 8 Sep 2010, 01:48 (16 years ago) parenta1dcba5
1 file changed+7−3
Data/Text/Encoding/Error.hs+7−3
Data/Text/Encoding/Error.hs+7−3
@@ -62,7 +62,11 @@ import Numeric (showHex)
6262-- use the description provided to construct a more helpful error
6363-- report.
6464type OnError a b = String -> Maybe a -> Maybe b
65+
66+-- | A handler for a decoding error.
6567type OnDecodeError = OnError Word8 Char
68+
69+-- | A handler for an encoding error.
6670type OnEncodeError = OnError Char Word8
6771
6872-- | An exception type for representing Unicode encoding errors.
@@ -91,16 +95,16 @@ instance Show UnicodeException where
9195instance Exception UnicodeException
9296
9397-- | Throw a 'UnicodeException' if decoding fails.
94−strictDecode :: OnError Word8 Char
98+strictDecode :: OnDecodeError
9599strictDecode desc c = throw (DecodeError desc c)
96100
97101-- | Replace an invalid input byte with the Unicode replacement
98102-- character U+FFFD.
99−lenientDecode :: OnError Word8 Char
103+lenientDecode :: OnDecodeError
100104lenientDecode _ _ = Just '\xfffd'
101105
102106-- | Throw a 'UnicodeException' if encoding fails.
103−strictEncode :: OnError Char Word8
107+strictEncode :: OnEncodeError
104108strictEncode desc c = throw (EncodeError desc c)
105109
106110-- | Ignore an invalid input, substituting nothing in the output.