<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Hi,</div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><br class=""></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">I’m trying to build up a list of all folders (including subfolders) from a given root folder.</div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><br class=""></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">So I have</div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><br class=""></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">folders :: FilePath -> IO [FilePath]<o:p class=""></o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">folders fp = do <o:p class=""></o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""> all <- getDirectoryContents fp<o:p class=""></o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 11pt;" class=""> filterM doesDirectoryExist $ map (fp </>) all</span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""></o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""> </div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">and this just gets the immediate folders within the given folder. </div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><br class=""></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">I’m stuck on how to recursively call folders and build up the IO [FilePath]</div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><br class=""></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><br class=""></div><div style="margin: 0cm 0cm 0.0001pt;" class=""><div style="margin: 0cm 0cm 0.0001pt;" class=""><font face="Calibri, sans-serif" class=""><span style="font-size: 15px;" class="">folders :: FilePath -> IO [FilePath]</span></font></div><div style="margin: 0cm 0cm 0.0001pt;" class=""><font face="Calibri, sans-serif" class=""><span style="font-size: 15px;" class="">folders fp = do</span></font></div><div style="margin: 0cm 0cm 0.0001pt;" class=""><font face="Calibri, sans-serif" class=""><span style="font-size: 15px;" class=""> all <- getDirectoryContents fp</span></font></div><div style="margin: 0cm 0cm 0.0001pt;" class=""><font face="Calibri, sans-serif" class=""><span style="font-size: 15px;" class=""> -- z :: IO [FilePath]</span></font></div><div style="margin: 0cm 0cm 0.0001pt;" class=""><font face="Calibri, sans-serif" class=""><span style="font-size: 15px;" class=""> let z = filterM doesDirectoryExist $ map (fp </>) all</span></font></div><div style="margin: 0cm 0cm 0.0001pt;" class=""><font face="Calibri, sans-serif" class=""><span style="font-size: 15px;" class=""> — z’ :: [FilePath]</span></font></div><div style="margin: 0cm 0cm 0.0001pt;" class=""><font face="Calibri, sans-serif" class=""><span style="font-size: 15px;" class=""> z' <- z</span></font></div><div style="margin: 0cm 0cm 0.0001pt;" class=""><font face="Calibri, sans-serif" class=""><span style="font-size: 15px;" class=""> — ?? what should happen here?</span></font></div><div style="margin: 0cm 0cm 0.0001pt;" class=""><font face="Calibri, sans-serif" class=""><span style="font-size: 15px;" class=""> z : (map folders z’) </span></font></div><div style="margin: 0cm 0cm 0.0001pt;" class=""><font face="Calibri, sans-serif" class=""><span style="font-size: 15px;" class=""><br class=""></span></font></div><div style="margin: 0cm 0cm 0.0001pt;" class=""><font face="Calibri, sans-serif" class=""><span style="font-size: 15px;" class=""> </span></font></div><div style="margin: 0cm 0cm 0.0001pt;" class=""><font face="Calibri, sans-serif" class=""><span style="font-size: 15px;" class=""> Couldn't match expected type ‘[FilePath]’</span></font></div><div style="margin: 0cm 0cm 0.0001pt;" class=""><font face="Calibri, sans-serif" class=""><span style="font-size: 15px;" class=""> with actual type ‘IO [FilePath]’</span></font></div><div style="margin: 0cm 0cm 0.0001pt;" class=""><font face="Calibri, sans-serif" class=""><span style="font-size: 15px;" class=""> In the first argument of ‘(:)’, namely ‘z’</span></font></div><div style="margin: 0cm 0cm 0.0001pt;" class=""><font face="Calibri, sans-serif" class=""><span style="font-size: 15px;" class=""> In a stmt of a 'do' block: z : (map folders z')</span></font></div><div style="margin: 0cm 0cm 0.0001pt;" class=""><span style="font-size: 15px; font-family: Calibri, sans-serif;" class="">etc... </span></div></div><div style="margin: 0cm 0cm 0.0001pt;" class=""><div style="margin: 0cm 0cm 0.0001pt;" class=""><font face="Calibri, sans-serif" class=""><span style="font-size: 15px;" class=""> </span></font></div><div style="margin: 0cm 0cm 0.0001pt;" class=""><font face="Calibri, sans-serif" class=""><span style="font-size: 15px;" class=""><br class=""></span></font></div><div style="font-family: Calibri, sans-serif; font-size: 11pt;" class="">Thanks</div><div style="font-family: Calibri, sans-serif; font-size: 11pt;" class=""><br class=""></div><div style="font-family: Calibri, sans-serif; font-size: 11pt;" class="">Mike</div><div style="font-family: Calibri, sans-serif; font-size: 11pt;" class=""><br class=""></div><div style="font-family: Calibri, sans-serif; font-size: 11pt;" class=""><br class=""></div></div></body></html>