diff options
Diffstat (limited to 'Pipes')
-rw-r--r-- | Pipes/Text.hs | 6 | ||||
-rw-r--r-- | Pipes/Text/Encoding.hs | 21 | ||||
-rw-r--r-- | Pipes/Text/IO.hs | 3 |
3 files changed, 13 insertions, 17 deletions
diff --git a/Pipes/Text.hs b/Pipes/Text.hs index e41689c..de581ad 100644 --- a/Pipes/Text.hs +++ b/Pipes/Text.hs | |||
@@ -1,4 +1,4 @@ | |||
1 | {-# LANGUAGE RankNTypes, TypeFamilies, BangPatterns, Trustworthy #-} | 1 | {-# LANGUAGE RankNTypes, TypeFamilies, BangPatterns, Safe#-} |
2 | 2 | ||
3 | {-| The module @Pipes.Text@ closely follows @Pipes.ByteString@ from | 3 | {-| The module @Pipes.Text@ closely follows @Pipes.ByteString@ from |
4 | the @pipes-bytestring@ package. A draft tutorial can be found in | 4 | the @pipes-bytestring@ package. A draft tutorial can be found in |
@@ -79,9 +79,8 @@ module Pipes.Text ( | |||
79 | , module Pipes.Group | 79 | , module Pipes.Group |
80 | ) where | 80 | ) where |
81 | 81 | ||
82 | import Control.Applicative ((<*)) | ||
83 | import Control.Monad (liftM, join) | 82 | import Control.Monad (liftM, join) |
84 | import Control.Monad.Trans.State.Strict (StateT(..), modify) | 83 | import Control.Monad.Trans.State.Strict (modify) |
85 | import qualified Data.Text as T | 84 | import qualified Data.Text as T |
86 | import Data.Text (Text) | 85 | import Data.Text (Text) |
87 | import qualified Data.Text.Lazy as TL | 86 | import qualified Data.Text.Lazy as TL |
@@ -96,7 +95,6 @@ import qualified Pipes.Parse as PP | |||
96 | import Pipes.Parse (Parser) | 95 | import Pipes.Parse (Parser) |
97 | import qualified Pipes.Prelude as P | 96 | import qualified Pipes.Prelude as P |
98 | import Data.Char (isSpace) | 97 | import Data.Char (isSpace) |
99 | import Data.Word (Word8) | ||
100 | import Foreign.Storable (sizeOf) | 98 | import Foreign.Storable (sizeOf) |
101 | import Data.Bits (shiftL) | 99 | import Data.Bits (shiftL) |
102 | import Prelude hiding ( | 100 | import Prelude hiding ( |
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 |