@@ -40,11 +40,6 @@ module Data.Text.Encoding
4040 , decodeUtf32LEWith
4141 , decodeUtf32BEWith
4242
43- -- *** Stream oriented decoding
44- -- $stream
45- , streamDecodeUtf8With
46- , Decoding (.. )
47-
4843 -- *** Incremental UTF-8 decoding
4944 -- $incremental
5045 , decodeUtf8Chunk
@@ -65,8 +60,11 @@ module Data.Text.Encoding
6560 , decodeUtf32LE
6661 , decodeUtf32BE
6762
68- -- *** Stream oriented decoding
63+ -- ** Stream oriented decoding
64+ -- $stream
6965 , streamDecodeUtf8
66+ , streamDecodeUtf8With
67+ , Decoding (.. )
7068
7169 -- * Encoding Text to ByteStrings
7270 , encodeUtf8
@@ -255,16 +253,17 @@ foreign import ccall unsafe "_hs_text_is_ascii" c_is_ascii
255253-- $stream
256254--
257255-- The 'streamDecodeUtf8' and 'streamDecodeUtf8With' functions accept
258- -- a 'ByteString' that represents a possibly incomplete input (e.g. a
259- -- packet from a network stream) that may not end on a UTF-8 boundary.
256+ -- a strict 'ByteString' that represents a possibly incomplete input (e.g. a
257+ -- packet from a network stream) that may not end on a UTF-8 boundary
258+ -- and return 'Decoding', which consists of:
260259--
261- -- 1. The maximal prefix of 'Text' that could be decoded from the
260+ -- * The maximal prefix of 'Text' that could be decoded from the
262261-- given input.
263262--
264- -- 2. The suffix of the 'ByteString' that could not be decoded due to
263+ -- * The suffix of the 'ByteString' that could not be decoded due to
265264-- insufficient input.
266265--
267- -- 3. A function that accepts another 'ByteString'. That string will
266+ -- * A function that accepts another 'ByteString'. That string will
268267-- be assumed to directly follow the string that was passed as
269268-- input to the original function, and it will in turn be decoded.
270269--
@@ -305,10 +304,18 @@ foreign import ccall unsafe "_hs_text_is_ascii" c_is_ascii
305304-- If given invalid input, an exception will be thrown by the function
306305-- or continuation where it is encountered.
307306
308- -- | A stream oriented decoding result.
307+ -- | A stream- oriented decoding result (see 'streamDecodeUtf8' and 'streamDecodeUtf8With') .
309308--
310309-- @since 1.0.0.0
311- data Decoding = Some ! Text ! ByteString (ByteString -> Decoding )
310+ data Decoding = Some
311+ ! Text
312+ -- ^ The maximal prefix that could be decoded from the given input.
313+ ! ByteString
314+ -- ^ The remaining suffix of the input that could not be decoded
315+ -- (usually because the input breaks in the middle of UTF-8 character)
316+ (ByteString -> Decoding )
317+ -- ^ The continuation call which should be fed with the next
318+ -- chunk of the input.
312319
313320instance Show Decoding where
314321 showsPrec d (Some t bs _) = showParen (d > prec) $
@@ -317,8 +324,8 @@ instance Show Decoding where
317324 showString " _"
318325 where prec = 10 ; prec' = prec + 1
319326
320- -- | Decode, in a stream oriented way, a 'ByteString' containing UTF-8
321- -- encoded text that is known to be valid.
327+ -- | Initiate a stream- oriented decoding
328+ -- with a strict 'ByteString' containing UTF-8 data that is known to be valid.
322329--
323330-- If the input contains any invalid UTF-8 data, an exception will be
324331-- thrown (either by this function or a continuation) that cannot be
@@ -333,8 +340,8 @@ streamDecodeUtf8 ::
333340 ByteString -> Decoding
334341streamDecodeUtf8 = streamDecodeUtf8With strictDecode
335342
336- -- | Decode, in a stream oriented way, a lazy 'ByteString' containing UTF-8
337- -- encoded text .
343+ -- | Initiate a stream- oriented decoding
344+ -- with a strict 'ByteString' containing UTF-8 data .
338345--
339346-- @since 1.0.0.0
340347streamDecodeUtf8With ::
0 commit comments