diff --git a/dhall-nixpkgs/dhall-nixpkgs.cabal b/dhall-nixpkgs/dhall-nixpkgs.cabal index ad0d10b295..f30b1ca3a5 100644 --- a/dhall-nixpkgs/dhall-nixpkgs.cabal +++ b/dhall-nixpkgs/dhall-nixpkgs.cabal @@ -17,7 +17,7 @@ Build-Type: Simple Executable dhall-to-nixpkgs Main-Is: Main.hs Build-Depends: base >= 4.11 && < 5 - , aeson >= 1.0.0.0 && < 1.5 + , aeson >= 1.0.0.0 && < 1.6 , data-fix , dhall >= 1.32.0 && < 1.38 , foldl < 1.5 diff --git a/dhall-openapi/openapi-to-dhall/Main.hs b/dhall-openapi/openapi-to-dhall/Main.hs index 881cc45835..10812a981b 100644 --- a/dhall-openapi/openapi-to-dhall/Main.hs +++ b/dhall-openapi/openapi-to-dhall/Main.hs @@ -150,11 +150,15 @@ getAutoscaling ModelName{..} | otherwise = Nothing +isK8sNative :: ModelName -> Bool +isK8sNative ModelName{..} = Text.isPrefixOf "io.k8s." unModelName + preferStableResource :: DuplicateHandler preferStableResource (_, names) = do let issue112 = Ord.comparing getAutoscaling + let k8sOverCrd = Ord.comparing isK8sNative let defaultComparison = Ord.comparing getVersion - let comparison = issue112 <> defaultComparison + let comparison = issue112 <> k8sOverCrd <> defaultComparison return (List.maximumBy comparison names) skipDuplicatesHandler :: DuplicateHandler diff --git a/dhall-openapi/src/Dhall/Kubernetes/Convert.hs b/dhall-openapi/src/Dhall/Kubernetes/Convert.hs index f634ab8a0e..303da6293d 100644 --- a/dhall-openapi/src/Dhall/Kubernetes/Convert.hs +++ b/dhall-openapi/src/Dhall/Kubernetes/Convert.hs @@ -270,7 +270,7 @@ getImportsMap prefixMap duplicateNameHandler objectNames folder toInclude namespacedToSimple = Data.Map.fromList $ mapMaybe selectObject $ Data.Map.toList $ groupByObjectName objectNames - -- | Given a list of fully namespaced bjects, it will group them by the + -- | Given a list of fully namespaced objects, it will group them by the -- object name groupByObjectName :: [ModelName] -> Data.Map.Map Text [ModelName] groupByObjectName modelNames = Data.Map.unionsWith (<>) diff --git a/dhall/ghc-src/Dhall/Import/HTTP.hs b/dhall/ghc-src/Dhall/Import/HTTP.hs index 9e800f3b34..81e2c8dcd2 100644 --- a/dhall/ghc-src/Dhall/Import/HTTP.hs +++ b/dhall/ghc-src/Dhall/Import/HTTP.hs @@ -11,6 +11,7 @@ import Control.Monad.Trans.State.Strict (StateT) import Data.ByteString (ByteString) import Data.CaseInsensitive (CI) import Data.Dynamic (toDyn) +import Data.List.NonEmpty (NonEmpty(..)) import Dhall.Core ( Import (..) , ImportHashed (..) @@ -29,7 +30,6 @@ import Network.HTTP.Client import qualified Control.Exception import qualified Control.Monad.Trans.State.Strict as State -import qualified Data.List.NonEmpty as NonEmpty import qualified Data.Text as Text import qualified Data.Text.Encoding import qualified Data.Text.Lazy @@ -266,11 +266,15 @@ fetchFromHttpUrl childURL mheaders = do Status {..} <- State.get - let Chained parentImport = NonEmpty.head _stack + case _stack of + -- We ignore the first import in the stack since that is the same import + -- as the `childUrl` + _ :| Chained parentImport : _ -> do + let parentImportType = importType (importHashed parentImport) - let parentImportType = importType (importHashed parentImport) - - corsCompliant parentImportType childURL (HTTP.responseHeaders response) + corsCompliant parentImportType childURL (HTTP.responseHeaders response) + _ -> do + return () let bytes = HTTP.responseBody response diff --git a/dhall/src/Dhall.hs b/dhall/src/Dhall.hs index 17f648cc1d..3f6f712a33 100644 --- a/dhall/src/Dhall.hs +++ b/dhall/src/Dhall.hs @@ -353,14 +353,15 @@ instance (Pretty s, Pretty a, Typeable s, Typeable a) => Show (InvalidDecoder s show InvalidDecoder { .. } = _ERROR <> ": Invalid Dhall.Decoder \n\ \ \n\ - \Every Decoder must provide an extract function that succeeds if an expression \n\ - \matches the expected type. You provided a Decoder that disobeys this contract \n\ + \Every Decoder must provide an extract function that does not fail with a type \n\ + \error if an expression matches the expected type. You provided a Decoder that \n\ + \disobeys this contract \n\ \ \n\ \The Decoder provided has the expected dhall type: \n\ \ \n\ \" <> show txt0 <> "\n\ \ \n\ - \and it couldn't extract a value from the well-typed expression: \n\ + \and it threw a type error during extraction from the well-typed expression: \n\ \ \n\ \" <> show txt1 <> "\n\ \ \n" diff --git a/dhall/tests/Dhall/Test/Dhall.hs b/dhall/tests/Dhall/Test/Dhall.hs index 4ec07ebb77..3f24f79e8f 100644 --- a/dhall/tests/Dhall/Test/Dhall.hs +++ b/dhall/tests/Dhall/Test/Dhall.hs @@ -92,14 +92,15 @@ shouldShowDetailedTypeError = testCase "detailed TypeError" $ do let expectedMsg = "\ESC[1;31mError\ESC[0m: Invalid Dhall.Decoder \n\ \ \n\ - \Every Decoder must provide an extract function that succeeds if an expression \n\ - \matches the expected type. You provided a Decoder that disobeys this contract \n\ + \Every Decoder must provide an extract function that does not fail with a type \n\ + \error if an expression matches the expected type. You provided a Decoder that \n\ + \disobeys this contract \n\ \ \n\ \The Decoder provided has the expected dhall type: \n\ \ \n\ \↳ { bar : Natural, foo : Text }\n\ \ \n\ - \and it couldn't extract a value from the well-typed expression: \n\ + \and it threw a type error during extraction from the well-typed expression: \n\ \ \n\ \↳ { bar = 0, foo = \"foo\" }\n\ \ \n"