Created
June 11, 2012 15:04
-
-
Save Jxck/2910543 to your computer and use it in GitHub Desktop.
cleanup without .hs files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import System.Directory | |
import Data.List | |
findDotIndex :: String -> Int | |
findDotIndex a = case findIndex (=='.') a of | |
Just x -> x | |
otherwise -> 0 | |
splitAtDot :: String -> (String, String) | |
splitAtDot x = splitAt (findDotIndex x) x | |
forRemove :: (String, String) -> Bool | |
forRemove (_, ".") = False | |
forRemove (_, "..") = False | |
forRemove (_, ".hs") = False | |
forRemove (_, ".git") = False | |
forRemove (_, "cleanup") = False | |
forRemove _ = True | |
main = do | |
d <- getCurrentDirectory | |
c <- getDirectoryContents d | |
let splitted = map splitAtDot c | |
let target = filter forRemove splitted | |
let targetFiles = map (\(a, b) -> a ++ b) target | |
mapM (\file -> removeFile file) targetFiles |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment