From 7faef8bceff2440056da59920fb932b5b76f6541 Mon Sep 17 00:00:00 2001 From: michaelt Date: Tue, 22 Oct 2013 18:40:23 -0400 Subject: [PATCH] new module names --- Data/Text/Pipes.hs => Pipes/Text.hs | 49 +++++++++++++++++++++++- {Data/Text/Pipes => Pipes/Text}/Parse.hs | 2 +- text-pipes.cabal | 4 +- 3 files changed, 51 insertions(+), 4 deletions(-) rename Data/Text/Pipes.hs => Pipes/Text.hs (94%) rename {Data/Text/Pipes => Pipes/Text}/Parse.hs (99%) diff --git a/Data/Text/Pipes.hs b/Pipes/Text.hs similarity index 94% rename from Data/Text/Pipes.hs rename to 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 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 () diff --git a/Data/Text/Pipes/Parse.hs b/Pipes/Text/Parse.hs similarity index 99% rename from Data/Text/Pipes/Parse.hs rename to Pipes/Text/Parse.hs index 675c7aa..8c3a13e 100644 --- a/Data/Text/Pipes/Parse.hs +++ b/Pipes/Text/Parse.hs @@ -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, 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 @@ -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 , -- 2.41.0