Skip to content
2 changes: 1 addition & 1 deletion dhall/dhall-lang
Submodule dhall-lang updated 92 files
+2 −2 .github/CONTRIBUTING.md
+44 −0 CHANGELOG.md
+17 −31 Prelude/JSON/renderAs.dhall
+17 −25 Prelude/List/fold.dhall
+60 −0 Prelude/List/foldLeft.dhall
+3 −0 Prelude/List/package.dhall
+8 −15 Prelude/Natural/fold.dhall
+9 −0 Prelude/NonEmpty/Type.dhall
+32 −0 Prelude/NonEmpty/all.dhall
+32 −0 Prelude/NonEmpty/any.dhall
+58 −0 Prelude/NonEmpty/concat.dhall
+53 −0 Prelude/NonEmpty/concatMap.dhall
+12 −0 Prelude/NonEmpty/head.dhall
+31 −0 Prelude/NonEmpty/index.dhall
+39 −0 Prelude/NonEmpty/indexed.dhall
+16 −0 Prelude/NonEmpty/last.dhall
+15 −0 Prelude/NonEmpty/length.dhall
+17 −0 Prelude/NonEmpty/make.dhall
+28 −0 Prelude/NonEmpty/map.dhall
+55 −0 Prelude/NonEmpty/package.dhall
+33 −0 Prelude/NonEmpty/reverse.dhall
+97 −0 Prelude/NonEmpty/shifted.dhall
+13 −0 Prelude/NonEmpty/singleton.dhall
+16 −0 Prelude/NonEmpty/toList.dhall
+56 −0 Prelude/NonEmpty/unzip.dhall
+61 −0 Prelude/NonEmpty/zip.dhall
+2 −3 Prelude/Optional/fold.dhall
+1 −1 Prelude/XML/package.dhall
+1 −1 Prelude/XML/render
+14 −12 Prelude/XML/render.dhall
+5 −2 Prelude/package.dhall
+1 −1 nixops/logical.nix
+4 −4 nixops/overlay.nix
+15 −0 nixops/packages/Prelude_20_2_0.nix
+1 −0 nixops/store.nix
+1 −1 standard/Parser.hs
+2 −2 standard/dhall.abnf
+41 −13 standard/imports.md
+1 −1 standard/versioning.md
+1 −1 tests/import/data/cycle.dhall
+1 −0 tests/import/data/doesNotParse.dhall
+0 −1 tests/import/failure/cycle.dhall
+0 −1 tests/import/failure/importBoundary.dhall
+1 −0 tests/import/failure/unit/Cycle.dhall
+1 −0 tests/import/failure/unit/DontRecoverCycle.dhall
+3 −0 tests/import/failure/unit/DontRecoverHashMismatch.dhall
+1 −0 tests/import/failure/unit/DontRecoverParseError.dhall
+1 −0 tests/import/failure/unit/DontRecoverTypeError.dhall
+0 −0 tests/import/failure/unit/EnvFromRemote.dhall
+1 −0 tests/import/failure/unit/FileMissing.dhall
+0 −0 tests/import/failure/unit/HashMismatch.dhall
+2 −0 tests/import/failure/unit/HashMismatch2.dhall
+0 −0 tests/import/failure/unit/Missing.dhall
+1 −0 tests/import/failure/unit/VarAcrossImportBoundary.dhall
+0 −1 tests/import/success/unit/AlternativeHashMismatchA.dhall
+0 −1 tests/import/success/unit/AlternativeHashMismatchB.dhall
+0 −1 tests/import/success/unit/AlternativeParseErrorA.dhall
+0 −1 tests/import/success/unit/AlternativeParseErrorB.dhall
+0 −1 tests/import/success/unit/AlternativeTypeErrorA.dhall
+0 −1 tests/import/success/unit/AlternativeTypeErrorB.dhall
+1 −0 tests/import/success/unit/AlternativeWithVariableA.dhall
+1 −0 tests/import/success/unit/AlternativeWithVariableB.dhall
+1 −0 tests/import/success/unit/AlternativeWithWrongVariable1A.dhall
+1 −0 tests/import/success/unit/AlternativeWithWrongVariable1B.dhall
+1 −0 tests/import/success/unit/AlternativeWithWrongVariable2A.dhall
+1 −0 tests/import/success/unit/AlternativeWithWrongVariable2B.dhall
+5 −0 tests/import/success/unit/DontCacheIfHashA.dhall
+1 −0 tests/import/success/unit/DontCacheIfHashB.dhall
+2 −0 tests/import/success/unit/MixImportModesA.dhall
+1 −0 tests/import/success/unit/MixImportModesB.dhall
+1 −0 tests/import/success/unit/RecoverTransitiveFailureA.dhall
+1 −0 tests/import/success/unit/RecoverTransitiveFailureB.dhall
+1 −0 tests/import/success/unit/cors/PreludeA.dhall
+1 −0 tests/import/success/unit/cors/PreludeB.dhall
+1 −0 tests/normalization/success/regression/ComplexRecordSimplificationA.dhall
+3 −0 tests/normalization/success/regression/ComplexRecordSimplificationB.dhall
+1 −0 tests/normalization/success/regression/ToMapQuotedFieldsA.dhall
+1 −0 tests/normalization/success/regression/ToMapQuotedFieldsB.dhall
+1 −0 tests/normalization/success/unit/RecordSortFieldsA.dhall
+1 −0 tests/normalization/success/unit/RecordSortFieldsB.dhall
+1 −0 tests/normalization/success/unit/RecordTypeSortFieldsA.dhall
+1 −0 tests/normalization/success/unit/RecordTypeSortFieldsB.dhall
+1 −0 tests/normalization/success/unit/TextReplaceOverlappingA.dhall
+1 −0 tests/normalization/success/unit/TextReplaceOverlappingB.dhall
+3 −0 tests/parser/success/unit/ShebangNixA.dhall
+1 −0 tests/parser/success/unit/ShebangNixB.dhallb
+1 −0 tests/parser/success/unit/ShebangNixB.diag
+1 −0 tests/type-inference/failure/unit/AssertAlphaTrap2.dhall
+1 −0 tests/type-inference/failure/unit/WithInfersKind.dhall
+93 −0 tests/type-inference/success/preludeB.dhall
+1 −0 tests/type-inference/success/unit/WithInfersKindA.dhall
+1 −0 tests/type-inference/success/unit/WithInfersKindB.dhall
28 changes: 24 additions & 4 deletions dhall/src/Dhall/Import.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveDataTypeable #-}
Expand All @@ -7,6 +8,7 @@
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ViewPatterns #-}

{-# OPTIONS_GHC -Wall #-}
Expand Down Expand Up @@ -167,6 +169,7 @@ import Data.List.NonEmpty (NonEmpty (..))
import Data.Text (Text)
import Data.Typeable (Typeable)
import Data.Void (Void, absurd)
import Dhall.TypeCheck (TypeError)

import Dhall.Syntax
( Chunks (..)
Expand Down Expand Up @@ -201,6 +204,7 @@ import Lens.Family.State.Strict (zoom)

import qualified Codec.CBOR.Write as Write
import qualified Codec.Serialise
import qualified Control.Exception as Exception
import qualified Control.Monad.State.Strict as State
import qualified Control.Monad.Trans.Maybe as Maybe
import qualified Data.ByteString
Expand Down Expand Up @@ -1157,11 +1161,27 @@ loadWith expr₀ = case expr₀ of

ImportAlt a b -> loadWith a `catch` handler₀
where
handler₀ (SourcedException (Src begin _ text₀) (MissingImports es₀)) =
loadWith b `catch` handler₁
is :: forall e . Exception e => SomeException -> Bool
is exception =
not (null (Exception.fromException @e exception))

isNotResolutionError exception =
is @(Imported (TypeError Src Void)) exception
|| is @(Imported Cycle ) exception
|| is @(Imported HashMismatch ) exception
|| is @(Imported ParseError ) exception

handler₀ exception₀@(SourcedException (Src begin _ text₀) (MissingImports es₀))
| any isNotResolutionError es₀ =
throwM exception₀
| otherwise = do
loadWith b `catch` handler₁
where
handler₁ (SourcedException (Src _ end text₁) (MissingImports es₁)) =
throwM (SourcedException (Src begin end text₂) (MissingImports (es₀ ++ es₁)))
handler₁ exception₁@(SourcedException (Src _ end text₁) (MissingImports es₁))
| any isNotResolutionError es₁ =
throwM exception₁
| otherwise =
throwM (SourcedException (Src begin end text₂) (MissingImports (es₀ ++ es₁)))
where
text₂ = text₀ <> " ? " <> text₁

Expand Down
2 changes: 1 addition & 1 deletion dhall/src/Dhall/Parser/Expression.hs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ parsers :: forall a. Parser a -> Parsers a
parsers embedded = Parsers {..}
where
completeExpression_ =
optional shebang *> whitespace *> expression <* whitespace
many shebang *> whitespace *> expression <* whitespace

shebang = do
_ <- text "#!"
Expand Down
5 changes: 2 additions & 3 deletions dhall/tests/Dhall/Test/Import.hs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,8 @@ failureTest path = do
let pathString = Text.unpack path

Tasty.HUnit.testCase pathString (do
text <- Text.IO.readFile pathString

actualExpr <- Core.throws (Parser.exprFromText mempty text)
actualExpr <- do
Core.throws (Parser.exprFromText mempty (Test.Util.toDhallPath path))

succeeded <- Exception.catch @SomeException
(do _ <- Test.Util.load actualExpr
Expand Down