import Control Monad import System Directory import System FilePath im

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
import Control.Monad
import System.Directory
import System.FilePath
import System.Environment
concatMapM f xs = liftM concat (mapM f xs)
hier dir = do
subdirs <- getDirectoryContents dir >>= return . filter (`notElem` [".", ".."])
lines <- filterM doesDirectoryExist (map (dir </>) subdirs) >>= concatMapM hier
return $ dir : map (" " ++) lines
main = do
dir:_ <- getArgs
hier dir >>= putStr . unlines