module Potoki.Core.IO.Fetch where
import Potoki.Core.Prelude
import Potoki.Core.Types
fetchAndHandleAll :: Fetch element -> IO () -> (element -> IO ()) -> IO ()
fetchAndHandleAll (Fetch fetchIO) onEnd onElement =
fix $ \ doLoop -> do
fetch <- fetchIO
case fetch of
Nothing -> onEnd
Just element -> onElement element >> doLoop
fetchAndHandle :: Fetch element -> IO a -> (element -> IO a) -> IO a
fetchAndHandle (Fetch fetchIO) onEnd onElement =
do
fetch <- fetchIO
case fetch of
Nothing -> onEnd
Just element -> onElement element