From 02f89dfe9b4787fbad5f3740ed1626203c474a2b Mon Sep 17 00:00:00 2001 From: michaelt Date: Mon, 17 Feb 2014 22:58:57 -0500 Subject: version 0.0.0.8 fwiw --- Pipes/Text.hs | 16 +++++++++------- Pipes/Text/Encoding.hs | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'Pipes') diff --git a/Pipes/Text.hs b/Pipes/Text.hs index d5b93f1..2f69806 100644 --- a/Pipes/Text.hs +++ b/Pipes/Text.hs @@ -1,7 +1,7 @@ {-# LANGUAGE RankNTypes, TypeFamilies, BangPatterns, Trustworthy #-} {-| This package provides @pipes@ utilities for \'text streams\', which are - streams of 'Text' chunks. The individual chunks are uniformly @strict@, and you + streams of 'Text' chunks. The individual chunks are uniformly @strict@, and thus you will generally want @Data.Text@ in scope. But the type @Producer Text m r@ is in some ways the pipes equivalent of the lazy @Text@ type. @@ -9,8 +9,8 @@ the 'pure' functions in . They transform, divide, group and fold text streams. Though @Producer Text m r@ - is \'effectful\' Text, functions - in this module are \'pure\' in the sense that they are uniformly monad-independent. + is the type of \'effectful Text\', the functions in this module are \'pure\' + in the sense that they are uniformly monad-independent. Simple IO operations are defined in @Pipes.Text.IO@ -- as lazy IO @Text@ operations are in @Data.Text.Lazy.IO@. Interoperation with @ByteString@ is provided in @Pipes.Text.Encoding@, which parallels @Data.Text.Lazy.Encoding@. @@ -49,7 +49,10 @@ sense.) Each such expression, e.g. 'lines', 'chunksOf' or 'splitAt', reduces to the - intuitively corresponding function when used with @view@ or @(^.)@. + intuitively corresponding function when used with @view@ or @(^.)@. The lens combinators + you will find indispensible are \'view\'/ '(^.)', 'zoom' and probably 'over', which + are supplied by both and + A more important difference the example reveals is in the types closely associated with the central type, @Producer Text m r@. In @Data.Text@ and @Data.Text.Lazy@ @@ -62,15 +65,14 @@ which relate a Text with a pair or list of Texts. The corresponding functions here (taking account of \'lensification\') are -> view . splitAt :: (Monad m, Integral n) -> => n -> Producer Text m r -> Producer Text.Text m (Producer Text.Text m r) +> view . splitAt :: (Monad m, Integral n) => n -> Producer Text m r -> Producer Text.Text m (Producer Text.Text m r) > view lines :: Monad m => Producer Text m r -> FreeT (Producer Text m) m r > view . chunksOf :: (Monad m, Integral n) => n -> Producer Text m r -> FreeT (Producer Text m) m r In the type @Producer Text m (Producer Text m r)@ the second element of the \'pair\' of of \'effectful Texts\' cannot simply be retrieved with 'snd'. This is an \'effectful\' pair, and one must work through the effects - of the first element to arrive at the second. Similarly in @FreeT (Producer Text m) m r@, + of the first element to arrive at the second Text stream. Similarly in @FreeT (Producer Text m) m r@, which corresponds with @[Text]@, on cannot simply drop 10 Producers and take the others; we can only get to the ones we want to take by working through their predecessors. diff --git a/Pipes/Text/Encoding.hs b/Pipes/Text/Encoding.hs index a1a0113..e6fc6bf 100644 --- a/Pipes/Text/Encoding.hs +++ b/Pipes/Text/Encoding.hs @@ -189,7 +189,7 @@ mkCodec dec enc = \k p0 -> fmap (\p -> join (for p (yield . enc))) (k (dec p0)) > decode utf8 Byte.stdin :: Producer Text IO (Producer ByteString IO r) > Bytes.stdin ^. utf8 :: Producer Text IO (Producer ByteString IO r) - Uses of a codec with @view@ / @(^.)@ / 'decode' can always be replaced by the specialized + Uses of a codec with @view@ or @(^.)@ or 'decode' can always be replaced by the specialized decoding functions exported here, e.g. > decodeUtf8 :: Producer ByteString m r -> Producer Text m (Producer ByteString m r) -- cgit v1.2.3