module Development.Shake.FileDetect
    ( getAts
    , getSats
    , getHats
    , getYml
    , getToml
    , getHs
    , getHappy
    , getAlex
    ) where

import           Data.Semigroup ((<>))
import Development.Shake

getYml :: Action [FilePath]
getYml = getAll ["yaml", "yml", "yamllint"]

getToml :: Action [FilePath]
getToml = getAll ["toml"]

getHs :: Action [FilePath]
getHs = getAll ["hs", "hs-boot", "hsig", "lhs"]

getHappy :: Action [FilePath]
getHappy = getAll ["y", "yl"]

getAlex :: Action [FilePath]
getAlex = getAll ["x"]

get :: String -> Action [FilePath]
get = getAll . pure

getAll :: [String] -> Action [FilePath]
getAll ss = getDirectoryFiles "" (("//*." ++) <$> ss)

getSats :: Action [FilePath]
getSats = get "sats"

getDats :: Action [FilePath]
getDats = get "dats"

getHats :: Action [FilePath]
getHats = get "hats"

getAts :: Action [FilePath]
getAts = (<>) <$> getDats <*> getSats