aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Pipes/Text.hs34
-rw-r--r--Pipes/Text/Encoding.hs6
2 files changed, 9 insertions, 31 deletions
diff --git a/Pipes/Text.hs b/Pipes/Text.hs
index 8221c01..68ede1a 100644
--- a/Pipes/Text.hs
+++ b/Pipes/Text.hs
@@ -165,47 +165,29 @@ module Pipes.Text (
165 , module Data.ByteString 165 , module Data.ByteString
166 , module Data.Text 166 , module Data.Text
167 , module Data.Profunctor 167 , module Data.Profunctor
168 , module Data.Word
169 , module Pipes.Parse 168 , module Pipes.Parse
170 , module Pipes.Group 169 , module Pipes.Group
171 ) where 170 ) where
172 171
173import Control.Applicative ((<*)) 172import Control.Applicative ((<*))
174import Control.Monad (liftM, unless, join) 173import Control.Monad (liftM, join)
175import Control.Monad.Trans.State.Strict (StateT(..), modify) 174import Control.Monad.Trans.State.Strict (StateT(..), modify)
176import Data.Monoid ((<>))
177import qualified Data.Text as T 175import qualified Data.Text as T
178import qualified Data.Text.IO as T
179import qualified Data.Text.Encoding as TE
180import qualified Data.Text.Encoding.Error as TE
181import Data.Text (Text) 176import Data.Text (Text)
182import qualified Data.Text.Lazy as TL 177import qualified Data.Text.Lazy as TL
183import qualified Data.Text.Lazy.IO as TL
184import Data.Text.Lazy.Internal (foldrChunks, defaultChunkSize) 178import Data.Text.Lazy.Internal (foldrChunks, defaultChunkSize)
185import Data.ByteString.Unsafe (unsafeTake, unsafeDrop)
186import Data.ByteString (ByteString) 179import Data.ByteString (ByteString)
187import qualified Data.ByteString as B
188import qualified Data.ByteString.Char8 as B8
189import Data.Char (ord, isSpace)
190import Data.Functor.Constant (Constant(Constant, getConstant)) 180import Data.Functor.Constant (Constant(Constant, getConstant))
191import Data.Functor.Identity (Identity) 181import Data.Functor.Identity (Identity)
192import Data.Profunctor (Profunctor) 182import Data.Profunctor (Profunctor)
193import qualified Data.Profunctor 183import qualified Data.Profunctor
194import qualified Data.List as List
195import Pipes 184import Pipes
196import qualified Pipes.ByteString as PB
197-- import Pipes.Text.Decoding
198import Pipes.Core (respond, Server')
199import Pipes.Group (concats, intercalates, FreeT(..), FreeF(..)) 185import Pipes.Group (concats, intercalates, FreeT(..), FreeF(..))
200import qualified Pipes.Group as PG 186import qualified Pipes.Group as PG
201import qualified Pipes.Parse as PP 187import qualified Pipes.Parse as PP
202import Pipes.Parse (Parser) 188import Pipes.Parse (Parser)
203
204import qualified Pipes.Prelude as P 189import qualified Pipes.Prelude as P
205import qualified System.IO as IO
206import Data.Char (isSpace) 190import Data.Char (isSpace)
207import Data.Word (Word8)
208import Data.Text.StreamDecoding
209 191
210import Prelude hiding ( 192import Prelude hiding (
211 all, 193 all,
@@ -272,13 +254,13 @@ concatMap f = P.map (T.concatMap f)
272-- | Transform a Pipe of 'Text' into a Pipe of 'ByteString's using UTF-8 254-- | Transform a Pipe of 'Text' into a Pipe of 'ByteString's using UTF-8
273-- encoding; @encodeUtf8 = Pipes.Prelude.map TE.encodeUtf8@ so more complex 255-- encoding; @encodeUtf8 = Pipes.Prelude.map TE.encodeUtf8@ so more complex
274-- encoding pipes can easily be constructed with the functions in @Data.Text.Encoding@ 256-- encoding pipes can easily be constructed with the functions in @Data.Text.Encoding@
275encodeUtf8 :: Monad m => Pipe Text ByteString m r 257-- encodeUtf8 :: Monad m => Pipe Text ByteString m r
276encodeUtf8 = P.map TE.encodeUtf8 258-- encodeUtf8 = P.map TE.encodeUtf8
277{-# INLINEABLE encodeUtf8 #-} 259-- {-# INLINEABLE encodeUtf8 #-}
278 260--
279{-# RULES "p >-> encodeUtf8" forall p . 261-- {-# RULES "p >-> encodeUtf8" forall p .
280 p >-> encodeUtf8 = for p (\txt -> yield (TE.encodeUtf8 txt)) 262-- p >-> encodeUtf8 = for p (\txt -> yield (TE.encodeUtf8 txt))
281 #-} 263-- #-}
282 264
283-- | Transform a Pipe of 'String's into one of 'Text' chunks 265-- | Transform a Pipe of 'String's into one of 'Text' chunks
284pack :: Monad m => Pipe String Text m r 266pack :: Monad m => Pipe String Text m r
diff --git a/Pipes/Text/Encoding.hs b/Pipes/Text/Encoding.hs
index 2bb5807..0ab6096 100644
--- a/Pipes/Text/Encoding.hs
+++ b/Pipes/Text/Encoding.hs
@@ -31,17 +31,13 @@ module Pipes.Text.Encoding
31import Data.Char (ord) 31import Data.Char (ord)
32import Data.ByteString as B 32import Data.ByteString as B
33import Data.ByteString (ByteString) 33import Data.ByteString (ByteString)
34import Data.ByteString.Internal as B
35import Data.ByteString.Char8 as B8 34import Data.ByteString.Char8 as B8
36import Data.Text (Text) 35import Data.Text (Text)
37import qualified Data.Text as T 36import qualified Data.Text as T
38import qualified Data.Text.Encoding as TE 37import qualified Data.Text.Encoding as TE
39import Data.Text.StreamDecoding 38import Data.Text.StreamDecoding
40import GHC.Word (Word8, Word32) 39import Control.Monad (join)
41import Data.Word (Word8, Word16)
42import Control.Monad
43import Pipes 40import Pipes
44import Pipes.Core
45 41
46 42
47 43