I'm walking a directory recursively, in a conventional way. This is a working prototype:
traverseFlatDst :: FilePath -> Int -> Int -> FilePath -> IO ()
traverseFlatDst dstRoot total totw srcDir = do
(dirs, files) <- listDir srcDir
mapM_ (\file -> putStrLn (printf "%s" (strp file))) files -- tracing
let traverse = traverseFlatDst dstRoot total totw
mapM_ traverse dirs
I have a not so unusual request: every trace line should be numbered (it is not really for tracing). Like this:
traverseFlatDst :: FilePath -> Int -> Int -> FilePath -> IO ()
traverseFlatDst dstRoot total totw srcDir = do
(dirs, files) <- listDir srcDir
mapM_ (\file -> putStrLn (printf "%d: %s" counterFromNowhere (strp file))) files
let traverse = traverseFlatDst dstRoot total totw
mapM_ traverse dirs
All the solutions I've seen so far are ugly beyond imagination, if applicable at all. Is there a nice way to manage it?