diff options
Diffstat (limited to 'Pipes/Text')
-rw-r--r-- | Pipes/Text/Encoding.hs | 21 | ||||
-rw-r--r-- | Pipes/Text/IO.hs | 3 |
2 files changed, 11 insertions, 13 deletions
diff --git a/Pipes/Text/Encoding.hs b/Pipes/Text/Encoding.hs index b6aa709..5a73aa9 100644 --- a/Pipes/Text/Encoding.hs +++ b/Pipes/Text/Encoding.hs | |||
@@ -53,7 +53,6 @@ module Pipes.Text.Encoding | |||
53 | import Data.Functor.Constant (Constant(..)) | 53 | import Data.Functor.Constant (Constant(..)) |
54 | import Data.Char (ord) | 54 | import Data.Char (ord) |
55 | import Data.ByteString as B | 55 | import Data.ByteString as B |
56 | import Data.ByteString (ByteString) | ||
57 | import Data.ByteString.Char8 as B8 | 56 | import Data.ByteString.Char8 as B8 |
58 | import Data.Text (Text) | 57 | import Data.Text (Text) |
59 | import qualified Data.Text as T | 58 | import qualified Data.Text as T |
@@ -61,7 +60,6 @@ import qualified Data.Text.Encoding as TE | |||
61 | import qualified Data.Streaming.Text as Stream | 60 | import qualified Data.Streaming.Text as Stream |
62 | import Data.Streaming.Text (DecodeResult(..)) | 61 | import Data.Streaming.Text (DecodeResult(..)) |
63 | import Control.Monad (join, liftM) | 62 | import Control.Monad (join, liftM) |
64 | import Data.Word (Word8) | ||
65 | import Pipes | 63 | import Pipes |
66 | 64 | ||
67 | 65 | ||
@@ -93,7 +91,7 @@ import Pipes | |||
93 | > for (decodeUtf16BE bytes) encodeUtf8 :: Producer ByteString IO (Producer ByteString IO ()) | 91 | > for (decodeUtf16BE bytes) encodeUtf8 :: Producer ByteString IO (Producer ByteString IO ()) |
94 | 92 | ||
95 | The bytestring producer that is returned begins with where utf16BE decoding | 93 | The bytestring producer that is returned begins with where utf16BE decoding |
96 | failed; it it didn't fail the producer is empty. | 94 | failed; if it didn't fail the producer is empty. |
97 | 95 | ||
98 | -} | 96 | -} |
99 | 97 | ||
@@ -231,7 +229,7 @@ decode codec a = getConstant (codec Constant a) | |||
231 | 229 | ||
232 | eof :: Monad m => Lens' (Producer Text m (Producer ByteString m r)) | 230 | eof :: Monad m => Lens' (Producer Text m (Producer ByteString m r)) |
233 | (Producer Text m (Either (Producer ByteString m r) r)) | 231 | (Producer Text m (Either (Producer ByteString m r) r)) |
234 | eof k p = fmap fromEither (k (toEither p)) where | 232 | eof k p0 = fmap fromEither (k (toEither p0)) where |
235 | 233 | ||
236 | fromEither = liftM (either id return) | 234 | fromEither = liftM (either id return) |
237 | 235 | ||
@@ -270,13 +268,14 @@ decodeStream :: Monad m | |||
270 | decodeStream = loop where | 268 | decodeStream = loop where |
271 | loop dec0 p = | 269 | loop dec0 p = |
272 | do x <- lift (next p) | 270 | do x <- lift (next p) |
273 | case x of Left r -> return (return r) | 271 | case x of |
274 | Right (chunk, p') -> case dec0 chunk of | 272 | Left r -> return (return r) |
275 | DecodeResultSuccess text dec -> do yield text | 273 | Right (chunk, p') -> case dec0 chunk of |
276 | loop dec p' | 274 | DecodeResultSuccess text dec -> do yield text |
277 | DecodeResultFailure text bs -> do yield text | 275 | loop dec p' |
278 | return (do yield bs | 276 | DecodeResultFailure text bs -> do yield text |
279 | p') | 277 | return (do yield bs |
278 | p') | ||
280 | {-# INLINABLE decodeStream#-} | 279 | {-# INLINABLE decodeStream#-} |
281 | 280 | ||
282 | 281 | ||
diff --git a/Pipes/Text/IO.hs b/Pipes/Text/IO.hs index 4a092b1..b7ef5cd 100644 --- a/Pipes/Text/IO.hs +++ b/Pipes/Text/IO.hs | |||
@@ -28,8 +28,7 @@ import qualified Data.Text as T | |||
28 | import qualified Data.Text.IO as T | 28 | import qualified Data.Text.IO as T |
29 | import Pipes | 29 | import Pipes |
30 | import qualified Pipes.Safe.Prelude as Safe | 30 | import qualified Pipes.Safe.Prelude as Safe |
31 | import qualified Pipes.Safe as Safe | 31 | import Pipes.Safe (MonadSafe(..)) |
32 | import Pipes.Safe (MonadSafe(..), Base(..)) | ||
33 | import Prelude hiding (readFile, writeFile) | 32 | import Prelude hiding (readFile, writeFile) |
34 | 33 | ||
35 | {- $textio | 34 | {- $textio |