diff options
-rw-r--r-- | Pipes/Text.hs (renamed from Data/Text/Pipes.hs) | 49 | ||||
-rw-r--r-- | Pipes/Text/Parse.hs (renamed from Data/Text/Pipes/Parse.hs) | 2 | ||||
-rw-r--r-- | text-pipes.cabal | 4 |
3 files changed, 51 insertions, 4 deletions
diff --git a/Data/Text/Pipes.hs b/Pipes/Text.hs index 3063aff..b0d90f0 100644 --- a/Data/Text/Pipes.hs +++ b/Pipes/Text.hs | |||
@@ -56,7 +56,7 @@ To stream from files, the following is perhaps more Prelude-like (note that it u | |||
56 | usage. | 56 | usage. |
57 | -} | 57 | -} |
58 | 58 | ||
59 | module Data.Text.Pipes ( | 59 | module Pipes.Text ( |
60 | -- * Producers | 60 | -- * Producers |
61 | fromLazy, | 61 | fromLazy, |
62 | stdin, | 62 | stdin, |
@@ -79,6 +79,10 @@ module Data.Text.Pipes ( | |||
79 | dropWhile, | 79 | dropWhile, |
80 | filter, | 80 | filter, |
81 | scan, | 81 | scan, |
82 | encodeUtf8, | ||
83 | pack, | ||
84 | unpack, | ||
85 | stripStart, | ||
82 | 86 | ||
83 | -- * Folds | 87 | -- * Folds |
84 | toLazy, | 88 | toLazy, |
@@ -307,6 +311,49 @@ concatMap | |||
307 | concatMap f = P.map (T.concatMap f) | 311 | concatMap f = P.map (T.concatMap f) |
308 | {-# INLINABLE concatMap #-} | 312 | {-# INLINABLE concatMap #-} |
309 | 313 | ||
314 | |||
315 | -- | Transform a Pipe of 'Text' into a Pipe of 'ByteString's using UTF-8 | ||
316 | -- encoding | ||
317 | encodeUtf8 :: Monad m => Pipe Text ByteString m r | ||
318 | encodeUtf8 = P.map TE.encodeUtf8 | ||
319 | {-# INLINEABLE encodeUtf8 #-} | ||
320 | |||
321 | --| Transform a Pipe of 'String's into one of 'Text' chunks | ||
322 | pack :: Monad m => Pipe String Text m r | ||
323 | pack = P.map T.pack | ||
324 | {-# INLINEABLE pack #-} | ||
325 | |||
326 | --| Transforma a Pipes of 'Text' chunks into one of 'String's | ||
327 | unpack :: Monad m => Pipe Text String m r | ||
328 | unpack = P.map T.unpack | ||
329 | {-# INLINEABLE unpack #-} | ||
330 | |||
331 | --| @toCaseFold@, @toLower@, @toUpper@ and @stripStart@ are standard 'Text' utility, | ||
332 | -- here acting on a 'Text' pipe, rather as they would on a lazy text | ||
333 | toCaseFold :: Monad m => Pipe Text Text m () | ||
334 | toCaseFold = P.map T.toCaseFold | ||
335 | {-# INLINEABLE toCaseFold #-} | ||
336 | |||
337 | --| lowercase incoming 'Text' | ||
338 | toLower :: Monad m => Pipe Text Text m () | ||
339 | toLower = P.map T.toLower | ||
340 | {-# INLINEABLE toLower #-} | ||
341 | |||
342 | --| uppercase incoming 'Text' | ||
343 | toUpper :: Monad m => Pipe Text Text m () | ||
344 | toUpper = P.map T.toUpper | ||
345 | {-# INLINEABLE toUpper #-} | ||
346 | |||
347 | --| Remove leading white space from an incoming succession of 'Text's | ||
348 | stripStart :: Monad m => Pipe Text Text m r | ||
349 | stripStart = do | ||
350 | chunk <- await | ||
351 | let text = T.stripStart chunk | ||
352 | if T.null text | ||
353 | then stripStart | ||
354 | else cat | ||
355 | {-# INLINEABLE stripStart #-} | ||
356 | |||
310 | -- | @(take n)@ only allows @n@ individual characters to pass; | 357 | -- | @(take n)@ only allows @n@ individual characters to pass; |
311 | -- contrast @Pipes.Prelude.take@ which would let @n@ chunks pass. | 358 | -- contrast @Pipes.Prelude.take@ which would let @n@ chunks pass. |
312 | take :: (Monad m, Integral a) => a -> Pipe Text Text m () | 359 | take :: (Monad m, Integral a) => a -> Pipe Text Text m () |
diff --git a/Data/Text/Pipes/Parse.hs b/Pipes/Text/Parse.hs index 675c7aa..8c3a13e 100644 --- a/Data/Text/Pipes/Parse.hs +++ b/Pipes/Text/Parse.hs | |||
@@ -1,6 +1,6 @@ | |||
1 | -- | Parsing utilities for characterstrings, in the style of @pipes-parse@ | 1 | -- | Parsing utilities for characterstrings, in the style of @pipes-parse@ |
2 | 2 | ||
3 | module Data.Text.Pipes.Parse ( | 3 | module Pipes.Text.Parse ( |
4 | -- * Parsers | 4 | -- * Parsers |
5 | nextChar, | 5 | nextChar, |
6 | drawChar, | 6 | drawChar, |
diff --git a/text-pipes.cabal b/text-pipes.cabal index cc5083a..e79f168 100644 --- a/text-pipes.cabal +++ b/text-pipes.cabal | |||
@@ -1,4 +1,4 @@ | |||
1 | name: text-pipes | 1 | name: pipes-text |
2 | version: 0.1.0.0 | 2 | version: 0.1.0.0 |
3 | synopsis: Text pipes. | 3 | synopsis: Text pipes. |
4 | description: Text pipes. | 4 | description: Text pipes. |
@@ -12,7 +12,7 @@ build-type: Simple | |||
12 | cabal-version: >=1.10 | 12 | cabal-version: >=1.10 |
13 | 13 | ||
14 | library | 14 | library |
15 | exposed-modules: Data.Text.Pipes, Data.Text.Pipes.Parse | 15 | exposed-modules: Pipes.Text, Pipes.Text.Parse |
16 | -- other-modules: | 16 | -- other-modules: |
17 | other-extensions: RankNTypes | 17 | other-extensions: RankNTypes |
18 | build-depends: base >= 4 && < 5 , | 18 | build-depends: base >= 4 && < 5 , |