aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormichaelt <what_is_it_to_do_anything@yahoo.com>2015-05-03 21:38:59 -0400
committermichaelt <what_is_it_to_do_anything@yahoo.com>2015-05-03 21:38:59 -0400
commit5e387e52ab52117a1b245508232cd04d79fff47d (patch)
tree39e8fa426da06ba2dc8b25fa0f55db09d54c45cd
parent77c322613ac2bddfb9604c63e4f2d486b8f6681e (diff)
downloadtext-pipes-5e387e52ab52117a1b245508232cd04d79fff47d.tar.gz
text-pipes-5e387e52ab52117a1b245508232cd04d79fff47d.tar.zst
text-pipes-5e387e52ab52117a1b245508232cd04d79fff47d.zip
wibble examples
-rw-r--r--Pipes/Text.hs2
-rw-r--r--examples/lines_url.hs22
2 files changed, 13 insertions, 11 deletions
diff --git a/Pipes/Text.hs b/Pipes/Text.hs
index 7a10f1e..e41689c 100644
--- a/Pipes/Text.hs
+++ b/Pipes/Text.hs
@@ -790,4 +790,4 @@ intercalate p0 = go0
790-} 790-}
791 791
792 792
793type Lens' a b = Functor f => (b -> f b) -> (a -> f a) 793type Lens' a b = forall f . Functor f => (b -> f b) -> (a -> f a)
diff --git a/examples/lines_url.hs b/examples/lines_url.hs
index b676656..ebc04e5 100644
--- a/examples/lines_url.hs
+++ b/examples/lines_url.hs
@@ -23,15 +23,17 @@ main = do
23 -- "http://www.gutenberg.org/files/10/10-h/10-h.htm" 23 -- "http://www.gutenberg.org/files/10/10-h/10-h.htm"
24 withManager tlsManagerSettings $ \m -> 24 withManager tlsManagerSettings $ \m ->
25 withHTTP req m $ \resp -> void $ runEffect $ 25 withHTTP req m $ \resp -> void $ runEffect $
26 number_lines_of (responseBody resp ^. utf8 . lines) >-> toHandle IO.stdout 26 number_lines_of (responseBody resp ^. utf8 . lines) >-> toHandle IO.stdout
27 27
28number_lines_of :: Monad m => FreeT (Producer Text m) m bad -> Producer Text m bad 28number_lines_of :: Monad m => FreeT (Producer Text m) m r -> Producer Text m r
29number_lines_of = number_loop (1 :: Int) where 29number_lines_of = number_loop (1 :: Int) where
30 number_loop n freeProducers = do 30 number_loop n free = do
31 freeProducer <- lift $ runFreeT freeProducers 31 fproducer <- lift $ runFreeT free
32 case freeProducer of 32 case fproducer of
33 Pure badbytes -> do yield $ T.pack "\n" 33 Pure badbytes -> do
34 return badbytes -- these could be inspected ... 34 yield $ T.pack "\n"
35 Free p -> do yield $ T.pack ("\n" ++ show n ++ " ") 35 return badbytes -- these could be inspected ...
36 nextFreeProducers <- p 36 Free p -> do
37 number_loop (n+1) nextFreeProducers 37 yield $ T.pack ("\n" ++ show n ++ " ")
38 next_free <- p
39 number_loop (n+1) next_free