]> git.immae.eu Git - github/fretlink/text-pipes.git/commitdiff
new module names
authormichaelt <what_is_it_to_do_anything@yahoo.com>
Tue, 22 Oct 2013 22:40:23 +0000 (18:40 -0400)
committermichaelt <what_is_it_to_do_anything@yahoo.com>
Tue, 22 Oct 2013 22:40:23 +0000 (18:40 -0400)
Pipes/Text.hs [moved from Data/Text/Pipes.hs with 94% similarity]
Pipes/Text/Parse.hs [moved from Data/Text/Pipes/Parse.hs with 99% similarity]
text-pipes.cabal

similarity index 94%
rename from Data/Text/Pipes.hs
rename to Pipes/Text.hs
index 3063aff11de5cbfce247849a6f73fcc670a04f41..b0d90f0e706ff1dd21998174925edc9f203eac34 100644 (file)
@@ -56,7 +56,7 @@ To stream from files, the following is perhaps more Prelude-like (note that it u
     usage.
 -}
 
-module Data.Text.Pipes  (
+module Pipes.Text  (
     -- * Producers
     fromLazy,
     stdin,
@@ -79,6 +79,10 @@ module Data.Text.Pipes  (
     dropWhile,
     filter,
     scan,
+    encodeUtf8,
+    pack,
+    unpack,
+    stripStart,
 
     -- * Folds
     toLazy,
@@ -307,6 +311,49 @@ concatMap
 concatMap f = P.map (T.concatMap f)
 {-# INLINABLE concatMap #-}
 
+
+-- | Transform a Pipe of 'Text' into a Pipe of 'ByteString's using UTF-8
+-- encoding
+encodeUtf8 :: Monad m => Pipe Text ByteString m r
+encodeUtf8 = P.map TE.encodeUtf8
+{-# INLINEABLE encodeUtf8 #-}
+
+--| Transform a Pipe of 'String's into one of 'Text' chunks
+pack :: Monad m => Pipe String Text m r
+pack = P.map T.pack
+{-# INLINEABLE pack #-}
+
+--| Transforma a Pipes of 'Text' chunks into one of 'String's
+unpack :: Monad m => Pipe Text String m r
+unpack = P.map T.unpack
+{-# INLINEABLE unpack #-}
+
+--| @toCaseFold@, @toLower@, @toUpper@ and @stripStart@ are standard 'Text' utility, 
+-- here acting on a 'Text' pipe, rather as they would  on a lazy text
+toCaseFold :: Monad m => Pipe Text Text m ()
+toCaseFold = P.map T.toCaseFold
+{-# INLINEABLE toCaseFold #-}
+
+--| lowercase incoming 'Text'
+toLower :: Monad m => Pipe Text Text m ()
+toLower = P.map T.toLower
+{-# INLINEABLE toLower #-}
+
+--| uppercase incoming 'Text'
+toUpper :: Monad m => Pipe Text Text m ()
+toUpper = P.map T.toUpper
+{-# INLINEABLE toUpper #-}
+
+--| Remove leading white space from an incoming succession of 'Text's 
+stripStart :: Monad m => Pipe Text Text m r
+stripStart = do
+    chunk <- await
+    let text = T.stripStart chunk
+    if T.null text
+      then stripStart
+      else cat
+{-# INLINEABLE stripStart #-}
+
 -- | @(take n)@ only allows @n@ individual characters to pass; 
 --  contrast @Pipes.Prelude.take@ which would let @n@ chunks pass.
 take :: (Monad m, Integral a) => a -> Pipe Text Text m ()
similarity index 99%
rename from Data/Text/Pipes/Parse.hs
rename to Pipes/Text/Parse.hs
index 675c7aa4b97c026e397be4806cacf273ab142a4f..8c3a13e48ebab50f9b7c9177395b6cfb5eb800dc 100644 (file)
@@ -1,6 +1,6 @@
 -- | Parsing utilities for characterstrings, in the style of @pipes-parse@
 
-module Data.Text.Pipes.Parse (
+module Pipes.Text.Parse (
     -- * Parsers
     nextChar,
     drawChar,
index cc5083a99946804ef48da1124146fa131d7bd75d..e79f16889ce33a840ecdc05b214505fda76e3050 100644 (file)
@@ -1,4 +1,4 @@
-name:                text-pipes
+name:                pipes-text
 version:             0.1.0.0
 synopsis:            Text pipes.
 description:         Text pipes.
@@ -12,7 +12,7 @@ build-type:          Simple
 cabal-version:       >=1.10
 
 library
-  exposed-modules:     Data.Text.Pipes, Data.Text.Pipes.Parse
+  exposed-modules:     Pipes.Text, Pipes.Text.Parse
   -- other-modules:       
   other-extensions:    RankNTypes
   build-depends:       base         >= 4       && < 5  ,