<div dir="ltr"><div><div>Your "isOk" function will filter out hidden directories on Unix (which may be what you want?).<br><br></div>Otherwise: isOk = (`notElem` [".",".."])<br><br></div>Also "\x -> folders x" = "folders"<br></div><div class="gmail_extra"><br><div class="gmail_quote">2016-02-26 11:42 GMT+01:00 Mike Houghton <span dir="ltr"><<a href="mailto:mike_k_houghton@yahoo.co.uk" target="_blank">mike_k_houghton@yahoo.co.uk</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks.<br>
<br>
<br>
I sweated it bit more and got<br>
<br>
<br>
<br>
isOk FilePath -> Bool<br>
isOk = not . isPrefixOf "."<br>
<span class=""><br>
folders :: FilePath -> IO [FilePath]<br>
folders fp = do<br>
all <- getDirectoryContents fp<br>
</span> z' <- filterM doesDirectoryExist $ map (fp </>) (filter isOk all)<br>
x' <- mapM (\x -> folders x) z'<br>
return $ z' ++ (concat x') ::<br>
<br>
which seems to work.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
> On 25 Feb 2016, at 19:07, Imants Cekusins <<a href="mailto:imantc@gmail.com">imantc@gmail.com</a>> wrote:<br>
><br>
> Hello Mike,<br>
><br>
> below code find all files recursively from a starting point. It works.<br>
><br>
> You'd need to tweak it to find folders instead.<br>
><br>
><br>
> import System.Directory<br>
> import Data.List<br>
><br>
><br>
> findAllFiles::FilePath -> IO [FilePath]<br>
> findAllFiles base0 = gd1 base0<br>
>>> = \list1 -> concatMap' recurse3 list1<br>
> where gd1 d1 = filter f2 <$> (getDirectoryContents d1)<br>
> f2 "." = False<br>
> f2 ".." = False<br>
> f2 _ = True<br>
> recurse3 md3 = doesDirectoryExist md3full<br>
>>> = \isDir3 -><br>
> if isDir3 then findAllFiles md3full<br>
> else pure [md3full]<br>
> where md3full = base0 ++ "/" ++ md3<br>
><br>
><br>
><br>
> concatMap':: (a -> IO [b]) -> [a] -> IO [b]<br>
> concatMap' m0 list0 = sequence (m0 <$> list0)<br>
>>> = \list2 -> pure $ concat list2<br>
> _______________________________________________<br>
> Beginners mailing list<br>
> <a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</div></div></blockquote></div><br></div>