module Development.Shake.FileDetect
( getAts
, getSats
, getHats
, getCats
, getYml
, getToml
, getHs
, getHappy
, getAlex
, getShell
, getDhall
, getMadlang
, getC
, getRust
, getSixten
, getIdris
) where
import Data.Foldable (fold)
import Data.Semigroup ((<>))
import Development.Shake
getMadlang :: Action [FilePath]
getMadlang = getAll ["mad"]
getC :: Action [FilePath]
getC = getAll ["c"]
getDhall :: Action [FilePath]
getDhall = getAll ["dhall"]
getYml :: Action [FilePath]
getYml = getAll ["yaml", "yml", "yamllint"]
getToml :: Action [FilePath]
getToml = getAll ["toml"]
getSixten :: Action [FilePath]
getSixten = getAll ["vix"]
getIdris :: Action [FilePath]
getIdris = getAll ["idr"]
getRust :: Action [FilePath]
getRust = getAll ["rs"]
getHs :: [FilePath] -> Action [FilePath]
getHs files = fold <$> traverse (`getAllDir` ["hs", "hs-boot", "hsig", "lhs"]) files
getHappy :: Action [FilePath]
getHappy = getAll ["y", "yl"]
getAlex :: Action [FilePath]
getAlex = getAll ["x"]
getShell :: Action [FilePath]
getShell = getAll ["sh"]
get :: String -> Action [FilePath]
get = getAll . pure
getAll :: [String] -> Action [FilePath]
getAll = getAllDir ""
getAllDir :: FilePath -> [String] -> Action [FilePath]
getAllDir dir ss = getDirectoryFiles "" (((dir ++ "//*.") ++) <$> ss)
getCats :: Action [FilePath]
getCats = get "cats"
getSats :: Action [FilePath]
getSats = get "sats"
getDats :: Action [FilePath]
getDats = get "dats"
getHats :: Action [FilePath]
getHats = get "hats"
getAts :: Action [FilePath]
getAts = (<>) <$> getDats <*> getSats