-- | Functions in this module check for the presence of various build tools.
module Development.Shake.Check ( checkExecutable
                               -- * Helper functions for specific programs
                               , pandoc
                               , autoconf
                               , patsFilter
                               , valgrind
                               , hs2ats
                               , ghc
                               ) where

import           Control.Monad.IO.Class
import           Data.Maybe             (isJust)
import           System.Directory       (findExecutable)

checkExecutable :: (MonadIO m) => String -> m Bool
checkExecutable = fmap isJust . liftIO . findExecutable

pandoc :: (MonadIO m) => m Bool
pandoc = checkExecutable "pandoc"

autoconf :: (MonadIO m) => m Bool
autoconf = checkExecutable "autoconf"

patsFilter :: (MonadIO m) => m Bool
patsFilter = checkExecutable "pats-filter"

valgrind :: (MonadIO m) => m Bool
valgrind = checkExecutable "valgrind"

hs2ats :: (MonadIO m) => m Bool
hs2ats = checkExecutable "hs2ats"

ghc :: (MonadIO m) => m Bool
ghc = checkExecutable "ghc"