-- | The functions in this module get all files in the current directory with -- some extension. 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 -- | Get all files ending with @.mad@. 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"] -- | Get all haskell source files, including module signatures. 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" -- | Get files ending in @.sats@ or @.dats@. getAts :: Action [FilePath] getAts = (<>) <$> getDats <*> getSats