Skip to content

Instantly share code, notes, and snippets.

@aristidb
Created May 24, 2014 12:45
Show Gist options
  • Save aristidb/bc4eaa627335c1c4e9cc to your computer and use it in GitHub Desktop.
Save aristidb/bc4eaa627335c1c4e9cc to your computer and use it in GitHub Desktop.
{-# LANGUAGE ScopedTypeVariables #-}
import System.FilePath
import System.Directory
import Control.Exception
dirTree :: FilePath -> IO [FilePath]
dirTree f =
do names <- getDirectoryContents f `catch` (\(_ :: IOException) -> return [])
let paths = (map (f </>) . filter (`notElem` [".", ".."])) names
recursed <- mapM dirTree paths
return (f : concat recursed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment