aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/lines_url.hs22
1 files changed, 12 insertions, 10 deletions
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