dhall-yaml 1.2.10 → 1.2.11
raw patch · 6 files changed
+42/−12 lines, 6 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Dhall.Yaml: [preserveHeader] :: Options -> Bool
- Dhall.Yaml: Options :: Bool -> (Value -> Value) -> Bool -> Bool -> Conversion -> Maybe FilePath -> Maybe FilePath -> Bool -> Options
+ Dhall.Yaml: Options :: Bool -> (Value -> Value) -> Bool -> Bool -> Conversion -> Maybe FilePath -> Maybe FilePath -> Bool -> Bool -> Options
Files
- CHANGELOG.md +6/−0
- dhall-yaml.cabal +2/−2
- src/Dhall/Yaml.hs +18/−10
- tasty/Main.hs +4/−0
- tasty/data/preserve-header.dhall +6/−0
- tasty/data/preserve-header.yaml +6/−0
CHANGELOG.md view
@@ -1,3 +1,9 @@+1.2.11++* [Add new `--preserve-header` option](https://github.com/dhall-lang/dhall-haskell/pull/2410)+* Builds against newer dependencies+ * [`aeson-2.1`](https://github.com/dhall-lang/dhall-haskell/pull/2424)+ 1.2.10 * Build against `dhall-1.41`
dhall-yaml.cabal view
@@ -1,5 +1,5 @@ Name: dhall-yaml-Version: 1.2.10+Version: 1.2.11 Cabal-Version: >=1.10 Build-Type: Simple License: GPL-3@@ -34,7 +34,7 @@ HsYAML >= 0.2 && < 0.3 , HsYAML-aeson >= 0.2 && < 0.3 , base >= 4.11.0.0 && < 5 ,- aeson >= 1.0.0.0 && < 2.1 ,+ aeson >= 1.0.0.0 && < 2.2 , bytestring < 0.12, dhall >= 1.31.0 && < 1.42, dhall-json >= 1.6.0 && < 1.8 ,
src/Dhall/Yaml.hs view
@@ -12,19 +12,21 @@ import Data.ByteString (ByteString) import Data.ByteString.Lazy (toStrict) import Data.Text (Text)-import Dhall.JSON (SpecialDoubleMode (..), codeToValue)+import Dhall.JSON (SpecialDoubleMode (..), codeToHeaderAndValue) import Dhall.JSON.Yaml (Options (..))+import Dhall.Parser (Header (..)) import qualified Data.Aeson import qualified Data.ByteString-import qualified Data.Char as Char-import qualified Data.Text as Text+import qualified Data.Char as Char+import qualified Data.Text as Text+import qualified Data.Text.Encoding import qualified Data.Vector-import qualified Data.YAML as Y+import qualified Data.YAML as Y import qualified Data.YAML.Aeson-import qualified Data.YAML.Event as YE-import qualified Data.YAML.Schema as YS-import qualified Data.YAML.Token as YT+import qualified Data.YAML.Event as YE+import qualified Data.YAML.Schema as YS+import qualified Data.YAML.Token as YT import qualified Dhall import qualified Dhall.JSON.Yaml @@ -40,12 +42,18 @@ let explaining = if explain then Dhall.detailed else id - json <- omission <$> explaining (codeToValue conversion UseYAMLEncoding mFilePath code)+ let adapt (header, value) = (header, omission value) + (Header comment, json) <- adapt <$> explaining (codeToHeaderAndValue conversion UseYAMLEncoding mFilePath code)++ let suffix+ | preserveHeader = Data.Text.Encoding.encodeUtf8 comment+ | otherwise = mempty+ let header = if noEdit- then Dhall.JSON.Yaml.generatedCodeNotice- else mempty+ then Dhall.JSON.Yaml.generatedCodeNotice <> suffix+ else suffix return $ header <> jsonToYaml json documents quoted
tasty/Main.hs view
@@ -69,6 +69,10 @@ TestBoth , testYamlToDhall "./tasty/data/mergify"+ , testDhallToYaml+ Dhall.JSON.Yaml.defaultOptions{ preserveHeader = True }+ "./tasty/data/preserve-header"+ TestBoth ] testDhallToYaml :: Options -> String -> TestScope -> TestTree
+ tasty/data/preserve-header.dhall view
@@ -0,0 +1,6 @@+-- Test header preservation+--+-- Line comments strip the leading `--`+{- Block comments include the surrounding `{-` and `-}`+ -}+1
+ tasty/data/preserve-header.yaml view
@@ -0,0 +1,6 @@+# Test header preservation+#+# Line comments strip the leading `--`+#{- Block comments include the surrounding `{-` and `-}`+# -}+1