Recursively list directories in Haskell

import Directory

myVisit :: String -> IO [String]
myVisit path = do
    isFile <- doesFileExist path
    isDirectory <- doesDirectoryExist path
    print path
    if (path == ".") || (path == "..")
        then return []
        else if isFile
          then return [path]
          else if isDirectory
            then do
                unfilteredContents  x /= "." && x /= "..") unfilteredContents
                visitedDirectories <- mapM myVisit (map ((path ++ "/") ++) contentList)
                return (concat visitedDirectories)
            else return []

This code is the result of spending some good hours in the middle of the night, with lots of input from the very patient guys on the #haskell channel from Very interesting are the bugs of the code and what happens in functions using this code. This Haskell really puts me to work. But that next time.


Lasă un răspuns

Completează mai jos detaliile tale sau dă clic pe un icon pentru a te autentifica:


Comentezi folosind contul tău Dezautentificare / Schimbă )

Poză Twitter

Comentezi folosind contul tău Twitter. Dezautentificare / Schimbă )

Fotografie Facebook

Comentezi folosind contul tău Facebook. Dezautentificare / Schimbă )

Fotografie Google+

Comentezi folosind contul tău Google+. Dezautentificare / Schimbă )

Conectare la %s