Hello, I'm wondering if it is possible doing IO in terms of Arrow.
I got a function search all files under directory recursively and I'd like to refartoring using Arrow terms.
I tried to define a function like below but failed.
isDirExist = Kleisli doesDirectoryExist
Do I need to define a instance for IO to be Arrow? Or is there any existing solutions?
I'm a newbie of Haskell and thanks your help.
~~~~~
getFilesInDir :: FilePath -> IO [FilePath]
getFilesInDir inp = do
isDir <- doesDirectoryExist inp
files <- if isDir then
(do
names <- getDirectoryContents inp
forM [ inp </> x | x <- names, isNotSpecialDir x ] getFilesInDir)
else return [[inp]]
return $ concat files
~~~~~