In the Haskell Control.Arrow
documentation it talks about Kleisli arrows' relationship to monads, but it is not obvious to me how to use this. I have a function which I think fits with arrows except for it involving the IO monad, so I think Kleisli arrows may help.
Take the following function which returns pairs of original and modified filenames of a directory.
import System.Directory
import System.FilePath
datedFiles target = do
fns <- getDirectoryContents target
tms <- mapM (fmap show . getModificationTime) fns
return $
zip fns $
zipWith replaceBaseName fns $
zipWith (++) (map takeBaseName fns) tms
If I had to draw it out, it would be something like this:
I think it can benefit from the use of Kleisli arrows, but I don't know how. Can anyone provide guidance?