copyDir ::  FilePath -> FilePath -> IO ()
copyDir from to = do
  createDirectoryIfMissing False to
  entries <- getDirectoryContents from
  let entries' = filter (`notElem` [".", ".."]) entries
  forM_ entries' $ \name -> do
    let from' = from `combine` name
        to'   = to `combine` name
    isDirectory <- doesDirectoryExist from'
    if isDirectory then copyDir from' to' else copyFile from' to'

-- Write an empty file in target, or a file copied from the specified entry
-- template if present.
copyDir ::  FilePath -> FilePath -> IO ()
copyDir from to = do
  createDirectoryIfMissing False to
  entries <- getDirectoryContents from
  let entries' = filter (`notElem` [".", ".."]) entries
  forM_ entries' $ \name -> do
    let from' = from `combine` name
        to'   = to `combine` name
    isDirectory <- doesDirectoryExist from'
    if isDirectory then copyDir from' to' else copyFile from' to'

-- Write an empty file in target, or a file copied from the specified entry
-- template if present.
copyDir from to = do
  createDirectoryIfMissing False to
  entries <- getDirectoryContents from
  let entries' = filter (`notElem` [".", ".."]) entries
  forM_ entries' $ \name -> do
    let from' = from `combine` name
        to'   = to `combine` name
    isDirectory <- doesDirectoryExist from'
    if isDirectory then copyDir from' to' else copyFile from' to'

-- Write an empty file in target, or a file copied from the specified entry
-- template if present.