-- "http://www.gutenberg.org/files/10/10-h/10-h.htm"
withManager tlsManagerSettings $ \m ->
withHTTP req m $ \resp -> void $ runEffect $
- number_lines_of (responseBody resp ^. utf8 . lines) >-> toHandle IO.stdout
+ number_lines_of (responseBody resp ^. utf8 . lines) >-> toHandle IO.stdout
-number_lines_of :: Monad m => FreeT (Producer Text m) m bad -> Producer Text m bad
+number_lines_of :: Monad m => FreeT (Producer Text m) m r -> Producer Text m r
number_lines_of = number_loop (1 :: Int) where
- number_loop n freeProducers = do
- freeProducer <- lift $ runFreeT freeProducers
- case freeProducer of
- Pure badbytes -> do yield $ T.pack "\n"
- return badbytes -- these could be inspected ...
- Free p -> do yield $ T.pack ("\n" ++ show n ++ " ")
- nextFreeProducers <- p
- number_loop (n+1) nextFreeProducers
+ number_loop n free = do
+ fproducer <- lift $ runFreeT free
+ case fproducer of
+ Pure badbytes -> do
+ yield $ T.pack "\n"
+ return badbytes -- these could be inspected ...
+ Free p -> do
+ yield $ T.pack ("\n" ++ show n ++ " ")
+ next_free <- p
+ number_loop (n+1) next_free