module Development.Shake.Dhall ( needDhall
, needDhallCli
, dhallDeps
) where
import Control.Monad (filterM, (<=<))
import Control.Monad.IO.Class (liftIO)
import Data.Containers.ListUtils (nubOrd)
import Development.Shake (Action, Stdout (Stdout), command,
doesFileExist, need)
import Dhall.Dep
needDhall :: [FilePath] -> Action ()
needDhall fps =
need =<< liftIO (nubOrd . concat . (fps:) <$> traverse getAllFileDeps fps)
needDhallCli :: [FilePath] -> Action ()
needDhallCli =
need . concat <=< traverse dhallDeps
dhallDeps :: FilePath -> Action [FilePath]
dhallDeps inp = do
(Stdout out) <- command [] "dhall" ["resolve", "--transitive-dependencies", "--file", inp]
(inp:) <$> filterM doesFileExist (lines out)