diff options
Diffstat (limited to 'Pipes/Text.hs')
-rw-r--r-- | Pipes/Text.hs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Pipes/Text.hs b/Pipes/Text.hs index d0a219d..d5b93f1 100644 --- a/Pipes/Text.hs +++ b/Pipes/Text.hs | |||
@@ -45,9 +45,11 @@ | |||
45 | As this example shows, one superficial difference from @Data.Text.Lazy@ | 45 | As this example shows, one superficial difference from @Data.Text.Lazy@ |
46 | is that many of the operations, like 'lines', | 46 | is that many of the operations, like 'lines', |
47 | are \'lensified\'; this has a number of advantages where it is possible, in particular | 47 | are \'lensified\'; this has a number of advantages where it is possible, in particular |
48 | it facilitates their use with 'Parser's of Text in the general pipes sense. | 48 | it facilitates their use with 'Parser's of Text (in the general |
49 | Each such expression reduces to the naturally corresponding function when | 49 | <http://hackage.haskell.org/package/pipes-parse-3.0.1/docs/Pipes-Parse-Tutorial.html pipes-parse> |
50 | used with @view@ or @(^.)@. | 50 | sense.) |
51 | Each such expression, e.g. 'lines', 'chunksOf' or 'splitAt', reduces to the | ||
52 | intuitively corresponding function when used with @view@ or @(^.)@. | ||
51 | 53 | ||
52 | A more important difference the example reveals is in the types closely associated with | 54 | A more important difference the example reveals is in the types closely associated with |
53 | the central type, @Producer Text m r@. In @Data.Text@ and @Data.Text.Lazy@ | 55 | the central type, @Producer Text m r@. In @Data.Text@ and @Data.Text.Lazy@ |
@@ -55,6 +57,7 @@ | |||
55 | 57 | ||
56 | > splitAt :: Int -> Text -> (Text, Text) | 58 | > splitAt :: Int -> Text -> (Text, Text) |
57 | > lines :: Int -> Text -> [Text] | 59 | > lines :: Int -> Text -> [Text] |
60 | > chunksOf :: Int -> Text -> [Text] | ||
58 | 61 | ||
59 | which relate a Text with a pair or list of Texts. The corresponding functions here (taking | 62 | which relate a Text with a pair or list of Texts. The corresponding functions here (taking |
60 | account of \'lensification\') are | 63 | account of \'lensification\') are |
@@ -62,8 +65,9 @@ | |||
62 | > view . splitAt :: (Monad m, Integral n) | 65 | > view . splitAt :: (Monad m, Integral n) |
63 | > => 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) |
64 | > view lines :: Monad m => Producer Text m r -> FreeT (Producer Text m) m r | 67 | > 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 | ||
65 | 69 | ||
66 | In the type @Producer Text.Text m (Producer Text.Text m r)@ the second | 70 | In the type @Producer Text m (Producer Text m r)@ the second |
67 | element of the \'pair\' of of \'effectful Texts\' cannot simply be retrieved | 71 | element of the \'pair\' of of \'effectful Texts\' cannot simply be retrieved |
68 | with 'snd'. This is an \'effectful\' pair, and one must work through the effects | 72 | with 'snd'. This is an \'effectful\' pair, and one must work through the effects |
69 | of the first element to arrive at the second. Similarly in @FreeT (Producer Text m) m r@, | 73 | of the first element to arrive at the second. Similarly in @FreeT (Producer Text m) m r@, |
@@ -80,6 +84,7 @@ | |||
80 | 84 | ||
81 | > view . splitAt :: (Monad m, Integral n) => n -> Text m r -> Text m (Text m r) | 85 | > view . splitAt :: (Monad m, Integral n) => n -> Text m r -> Text m (Text m r) |
82 | > view lines :: (Monad m) => Text m r -> Texts m r | 86 | > view lines :: (Monad m) => Text m r -> Texts m r |
87 | > view . chunksOf :: (Monad m, Integral n) => n -> Text m r -> Texts m r | ||
83 | 88 | ||
84 | which brings one closer to the types of the similar functions in @Data.Text.Lazy@ | 89 | which brings one closer to the types of the similar functions in @Data.Text.Lazy@ |
85 | 90 | ||