Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dhall.Import.loadWithContext #215

Merged
merged 1 commit into from
Jan 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/Dhall/Import.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ module Dhall.Import (
exprFromPath
, load
, loadWith
, loadWithContext
, hashExpression
, hashExpressionToCode
, Cycle(..)
Expand Down Expand Up @@ -774,6 +775,15 @@ loadWith
-> m (Expr Src X)
loadWith from_path ctx = evalStatus (loadStaticWith from_path ctx)

-- | Resolve all imports within an expression using a custom typing context.
--
-- @load = loadWithContext Dhall.Context.empty@
loadWithContext
:: Dhall.Context.Context (Expr Src X)
-> Expr Src Path
-> IO (Expr Src X)
loadWithContext ctx = evalStatus (loadStaticIO ctx)

loadStaticWith
:: MonadCatch m
=> (Path -> StateT Status m (Expr Src Path))
Expand Down Expand Up @@ -849,7 +859,7 @@ evalStatus cb expr = State.evalStateT (fmap join (traverse cb expr)) emptyStatus

-- | Resolve all imports within an expression
load :: Expr Src Path -> IO (Expr Src X)
load = evalStatus (loadStaticIO Dhall.Context.empty)
load = loadWithContext Dhall.Context.empty

-- | Hash a fully resolved expression
hashExpression :: Expr s X -> Data.ByteString.ByteString
Expand Down