{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ViewPatterns #-}
module Rib.Parser.Dhall
(
parse,
)
where
import Development.Shake
import Dhall (FromDhall, auto, input)
import Path
import Relude
import Rib.Shake (ribInputDir)
import System.Directory
parse ::
FromDhall a =>
[Path Rel File] ->
Path Rel File ->
Action a
parse (map toFilePath -> deps) f = do
inputDir <- ribInputDir
need deps
s <- toText <$> readFile' (toFilePath $ inputDir </> f)
liftIO $ withCurrentDirectory (toFilePath inputDir) $
input auto s