cleanBuilds :: Int -> FilePath -> IO ()
cleanBuilds n path = do
  items <- getDirectoryContents path
  mapM_ (removeDirectoryRecursive . (path </>))
    . drop n
    . sortBy (\a b -> b `compare` a)
    . filter ("build." `isPrefixOf`)
    $ items
cleanBuilds :: Int -> FilePath -> IO ()
cleanBuilds n path = do
  items <- getDirectoryContents path
  mapM_ (removeDirectoryRecursive . (path </>))
    . drop n
    . sortBy (\a b -> b `compare` a)
    . filter ("build." `isPrefixOf`)
    $ items
cleanBuilds n path = do
  items <- getDirectoryContents path
  mapM_ (removeDirectoryRecursive . (path </>))
    . drop n
    . sortBy (\a b -> b `compare` a)
    . filter ("build." `isPrefixOf`)
    $ items