File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ Library
3636 Build-Depends :
3737 base >= 4.12 && < 5 ,
3838 dhall >= 1.39.0 && < 1.43 ,
39+ filepath < 1.6 ,
3940 tomland >= 1.3.2.0 && < 1.4 ,
4041 text >= 0.11.1.0 && < 2.2 ,
4142 containers >= 0.5.9 && < 0.8 ,
Original file line number Diff line number Diff line change @@ -10,13 +10,15 @@ module Dhall.Toml.Utils
1010
1111import Data.Text (Text )
1212import Data.Void (Void )
13+ import Dhall.Import (SemanticCacheMode (.. ))
1314import Dhall.Parser (Src )
1415
1516import qualified Data.Text.IO as Text.IO
1617import qualified Dhall.Core as Core
1718import qualified Dhall.Import
1819import qualified Dhall.Parser
1920import qualified Dhall.TypeCheck
21+ import qualified System.FilePath as FilePath
2022
2123-- | Read the file fileName and return the normalized Dhall AST
2224fileToDhall :: String -> IO (Core. Expr Src Void )
@@ -35,9 +37,15 @@ inputToDhall = do
3537-- by the parser for generating error messages.
3638textToDhall :: String -> Text -> IO (Core. Expr Src Void )
3739textToDhall fileName text = do
38- parsedExpression <-
40+ parsedExpression <- do
3941 Core. throws (Dhall.Parser. exprFromText fileName text)
40- resolvedExpression <- Dhall.Import. load parsedExpression
42+
43+ let directory = FilePath. takeDirectory fileName
44+
45+ resolvedExpression <- do
46+ Dhall.Import. loadRelativeTo directory UseSemanticCache parsedExpression
47+
4148 _ <- Core. throws (Dhall.TypeCheck. typeOf resolvedExpression)
49+
4250 return resolvedExpression
4351
You can’t perform that action at this time.
0 commit comments