Hi,
I’m trying to build up a list of all folders (including subfolders) from a given root folder.
So I have
folders :: FilePath -> IO [FilePath]
folders fp = do
all <- getDirectoryContents fp
filterM doesDirectoryExist $ map (fp </>) all
and this just gets the immediate folders within the given folder.
I’m stuck on how to recursively call folders and build up the IO [FilePath]
folders :: FilePath -> IO [FilePath]
folders fp = do
all <- getDirectoryContents fp
-- z :: IO [FilePath]
let z = filterM doesDirectoryExist $ map (fp </>) all
— z’ :: [FilePath]
z' <- z
— ?? what should happen here?
z : (map folders z’)
Couldn't match expected type ‘[FilePath]’
with actual type ‘IO [FilePath]’
In the first argument of ‘(:)’, namely ‘z’
In a stmt of a 'do' block: z : (map folders z')
etc...