import System.Environment import System.IO import System.Directory import Control.Monad notDotOrDotDot :: FilePath -> Bool notDotOrDotDot f = case f of "." -> False ".." -> False _ -> True concatPaths :: FilePath -> FilePath -> FilePath concatPaths p1 p2 = p1 ++ "/" ++ p2 listR :: FilePath -> IO [FilePath] listR f = do is_d <- doesDirectoryExist f if is_d then do files <- getDirectoryContents f subdirs <- mapM listR $ map (concatPaths f) $ filter notDotOrDotDot files return $ foldl (++) [f] subdirs else return [f] main = do file <- liftM head getArgs files <- listR file putStr $ unlines files