tagSources :: [(Text,[Text])] -> [FilePath] -> StackTag ()
tagSources srcs depsrcs = do

  let srcDir    = lookup "project-root" srcs
  let tagroot   = T.unpack . fromMaybe "." . listToMaybe . fromMaybe [] $ srcDir

  -- alternative pooled
  depTagFiles <- parTag srcs depsrcs

  -- map a tag command over all provided sources
  thisProj   <- runTagger (TagCmd Hasktags ETags "stack.tags" tagroot "project-root")
  taggedSrcs <- T.traverse (io . readFile) (rights (thisProj : depTagFiles))

  let errors = lefts (thisProj : depTagFiles)
  unless (null errors) $ do

      let pkg_errs = map (\(pkg,err) -> pkg ++ ": " ++ err) $ take 10 errors
      error $ unlines $
                   "[tag:error] stack-tag encountered errors creating tags"
                 : pkg_errs

  let xs = concatMap lines taggedSrcs
      ys = if False then (Set.toList . Set.fromList) xs else xs

  p $ "[tag:done] built & merged tags for " ++ show (length taggedSrcs) ++ " projects"
  io $ writeFile "TAGS" $ unlines ys
tagSources :: [(Text,[Text])] -> [FilePath] -> StackTag ()
tagSources srcs depsrcs = do

  let srcDir    = lookup "project-root" srcs
  let tagroot   = T.unpack . fromMaybe "." . listToMaybe . fromMaybe [] $ srcDir

  -- alternative pooled
  depTagFiles <- parTag srcs depsrcs

  -- map a tag command over all provided sources
  thisProj   <- runTagger (TagCmd Hasktags ETags "stack.tags" tagroot "project-root")
  taggedSrcs <- T.traverse (io . readFile) (rights (thisProj : depTagFiles))

  let errors = lefts (thisProj : depTagFiles)
  unless (null errors) $ do

      let pkg_errs = map (\(pkg,err) -> pkg ++ ": " ++ err) $ take 10 errors
      error $ unlines $
                   "[tag:error] stack-tag encountered errors creating tags"
                 : pkg_errs

  let xs = concatMap lines taggedSrcs
      ys = if False then (Set.toList . Set.fromList) xs else xs

  p $ "[tag:done] built & merged tags for " ++ show (length taggedSrcs) ++ " projects"
  io $ writeFile "TAGS" $ unlines ys
tagSources srcs depsrcs = do

  let srcDir    = lookup "project-root" srcs
  let tagroot   = T.unpack . fromMaybe "." . listToMaybe . fromMaybe [] $ srcDir

  -- alternative pooled
  depTagFiles <- parTag srcs depsrcs

  -- map a tag command over all provided sources
  thisProj   <- runTagger (TagCmd Hasktags ETags "stack.tags" tagroot "project-root")
  taggedSrcs <- T.traverse (io . readFile) (rights (thisProj : depTagFiles))

  let errors = lefts (thisProj : depTagFiles)
  unless (null errors) $ do

      let pkg_errs = map (\(pkg,err) -> pkg ++ ": " ++ err) $ take 10 errors
      error $ unlines $
                   "[tag:error] stack-tag encountered errors creating tags"
                 : pkg_errs

  let xs = concatMap lines taggedSrcs
      ys = if False then (Set.toList . Set.fromList) xs else xs

  p $ "[tag:done] built & merged tags for " ++ show (length taggedSrcs) ++ " projects"
  io $ writeFile "TAGS" $ unlines ys