aboutsummaryrefslogtreecommitdiffhomepage
path: root/Pipes/Text
diff options
context:
space:
mode:
Diffstat (limited to 'Pipes/Text')
-rw-r--r--Pipes/Text/Encoding.hs21
-rw-r--r--Pipes/Text/IO.hs3
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
53import Data.Functor.Constant (Constant(..)) 53import Data.Functor.Constant (Constant(..))
54import Data.Char (ord) 54import Data.Char (ord)
55import Data.ByteString as B 55import Data.ByteString as B
56import Data.ByteString (ByteString)
57import Data.ByteString.Char8 as B8 56import Data.ByteString.Char8 as B8
58import Data.Text (Text) 57import Data.Text (Text)
59import qualified Data.Text as T 58import qualified Data.Text as T
@@ -61,7 +60,6 @@ import qualified Data.Text.Encoding as TE
61import qualified Data.Streaming.Text as Stream 60import qualified Data.Streaming.Text as Stream
62import Data.Streaming.Text (DecodeResult(..)) 61import Data.Streaming.Text (DecodeResult(..))
63import Control.Monad (join, liftM) 62import Control.Monad (join, liftM)
64import Data.Word (Word8)
65import Pipes 63import 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
232eof :: Monad m => Lens' (Producer Text m (Producer ByteString m r)) 230eof :: 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))
234eof k p = fmap fromEither (k (toEither p)) where 232eof 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
270decodeStream = loop where 268decodeStream = 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
28import qualified Data.Text.IO as T 28import qualified Data.Text.IO as T
29import Pipes 29import Pipes
30import qualified Pipes.Safe.Prelude as Safe 30import qualified Pipes.Safe.Prelude as Safe
31import qualified Pipes.Safe as Safe 31import Pipes.Safe (MonadSafe(..))
32import Pipes.Safe (MonadSafe(..), Base(..))
33import Prelude hiding (readFile, writeFile) 32import Prelude hiding (readFile, writeFile)
34 33
35{- $textio 34{- $textio