aboutsummaryrefslogtreecommitdiffhomepage
path: root/Pipes
diff options
context:
space:
mode:
Diffstat (limited to 'Pipes')
-rw-r--r--Pipes/Text.hs16
-rw-r--r--Pipes/Text/Encoding.hs2
2 files changed, 10 insertions, 8 deletions
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 @@
1{-# LANGUAGE RankNTypes, TypeFamilies, BangPatterns, Trustworthy #-} 1{-# LANGUAGE RankNTypes, TypeFamilies, BangPatterns, Trustworthy #-}
2 2
3{-| This package provides @pipes@ utilities for \'text streams\', which are 3{-| This package provides @pipes@ utilities for \'text streams\', which are
4 streams of 'Text' chunks. The individual chunks are uniformly @strict@, and you 4 streams of 'Text' chunks. The individual chunks are uniformly @strict@, and thus you
5 will generally want @Data.Text@ in scope. But the type @Producer Text m r@ is 5 will generally want @Data.Text@ in scope. But the type @Producer Text m r@ is
6 in some ways the pipes equivalent of the lazy @Text@ type. 6 in some ways the pipes equivalent of the lazy @Text@ type.
7 7
@@ -9,8 +9,8 @@
9 the 'pure' functions in 9 the 'pure' functions in
10 <https://hackage.haskell.org/package/text-1.1.0.0/docs/Data-Text-Lazy.html Data.Text.Lazy>. 10 <https://hackage.haskell.org/package/text-1.1.0.0/docs/Data-Text-Lazy.html Data.Text.Lazy>.
11 They transform, divide, group and fold text streams. Though @Producer Text m r@ 11 They transform, divide, group and fold text streams. Though @Producer Text m r@
12 is \'effectful\' Text, functions 12 is the type of \'effectful Text\', the functions in this module are \'pure\'
13 in this module are \'pure\' in the sense that they are uniformly monad-independent. 13 in the sense that they are uniformly monad-independent.
14 Simple IO operations are defined in @Pipes.Text.IO@ -- as lazy IO @Text@ 14 Simple IO operations are defined in @Pipes.Text.IO@ -- as lazy IO @Text@
15 operations are in @Data.Text.Lazy.IO@. Interoperation with @ByteString@ 15 operations are in @Data.Text.Lazy.IO@. Interoperation with @ByteString@
16 is provided in @Pipes.Text.Encoding@, which parallels @Data.Text.Lazy.Encoding@. 16 is provided in @Pipes.Text.Encoding@, which parallels @Data.Text.Lazy.Encoding@.
@@ -49,7 +49,10 @@
49 <http://hackage.haskell.org/package/pipes-parse-3.0.1/docs/Pipes-Parse-Tutorial.html pipes-parse> 49 <http://hackage.haskell.org/package/pipes-parse-3.0.1/docs/Pipes-Parse-Tutorial.html pipes-parse>
50 sense.) 50 sense.)
51 Each such expression, e.g. 'lines', 'chunksOf' or 'splitAt', reduces to the 51 Each such expression, e.g. 'lines', 'chunksOf' or 'splitAt', reduces to the
52 intuitively corresponding function when used with @view@ or @(^.)@. 52 intuitively corresponding function when used with @view@ or @(^.)@. The lens combinators
53 you will find indispensible are \'view\'/ '(^.)', 'zoom' and probably 'over', which
54 are supplied by both <http://hackage.haskell.org/package/lens lens> and
55 <http://hackage.haskell.org/package/lens-family lens-family>
53 56
54 A more important difference the example reveals is in the types closely associated with 57 A more important difference the example reveals is in the types closely associated with
55 the central type, @Producer Text m r@. In @Data.Text@ and @Data.Text.Lazy@ 58 the central type, @Producer Text m r@. In @Data.Text@ and @Data.Text.Lazy@
@@ -62,15 +65,14 @@
62 which relate a Text with a pair or list of Texts. The corresponding functions here (taking 65 which relate a Text with a pair or list of Texts. The corresponding functions here (taking
63 account of \'lensification\') are 66 account of \'lensification\') are
64 67
65> view . splitAt :: (Monad m, Integral n) 68> view . splitAt :: (Monad m, Integral n) => n -> Producer Text m r -> Producer Text.Text m (Producer Text.Text m r)
66> => n -> Producer Text m r -> Producer Text.Text m (Producer Text.Text m r)
67> view lines :: Monad m => Producer Text m r -> FreeT (Producer Text m) m r 69> view lines :: Monad m => Producer Text m r -> FreeT (Producer Text m) m r
68> view . chunksOf :: (Monad m, Integral n) => n -> Producer Text m r -> FreeT (Producer Text m) m r 70> view . chunksOf :: (Monad m, Integral n) => n -> Producer Text m r -> FreeT (Producer Text m) m r
69 71
70 In the type @Producer Text m (Producer Text m r)@ the second 72 In the type @Producer Text m (Producer Text m r)@ the second
71 element of the \'pair\' of of \'effectful Texts\' cannot simply be retrieved 73 element of the \'pair\' of of \'effectful Texts\' cannot simply be retrieved
72 with 'snd'. This is an \'effectful\' pair, and one must work through the effects 74 with 'snd'. This is an \'effectful\' pair, and one must work through the effects
73 of the first element to arrive at the second. Similarly in @FreeT (Producer Text m) m r@, 75 of the first element to arrive at the second Text stream. Similarly in @FreeT (Producer Text m) m r@,
74 which corresponds with @[Text]@, on cannot simply drop 10 Producers and take the others; 76 which corresponds with @[Text]@, on cannot simply drop 10 Producers and take the others;
75 we can only get to the ones we want to take by working through their predecessors. 77 we can only get to the ones we want to take by working through their predecessors.
76 78
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))
189> decode utf8 Byte.stdin :: Producer Text IO (Producer ByteString IO r) 189> decode utf8 Byte.stdin :: Producer Text IO (Producer ByteString IO r)
190> Bytes.stdin ^. utf8 :: Producer Text IO (Producer ByteString IO r) 190> Bytes.stdin ^. utf8 :: Producer Text IO (Producer ByteString IO r)
191 191
192 Uses of a codec with @view@ / @(^.)@ / 'decode' can always be replaced by the specialized 192 Uses of a codec with @view@ or @(^.)@ or 'decode' can always be replaced by the specialized
193 decoding functions exported here, e.g. 193 decoding functions exported here, e.g.
194 194
195> decodeUtf8 :: Producer ByteString m r -> Producer Text m (Producer ByteString m r) 195> decodeUtf8 :: Producer ByteString m r -> Producer Text m (Producer ByteString m r)