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