File tree Expand file tree Collapse file tree 4 files changed +12
-11
lines changed
Expand file tree Collapse file tree 4 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -201,6 +201,7 @@ module Dhall.JSON (
201201 , omitEmpty
202202 , parsePreservationAndOmission
203203 , Conversion (.. )
204+ , defaultConversion
204205 , convertToHomogeneousMaps
205206 , parseConversion
206207 , SpecialDoubleMode (.. )
@@ -646,6 +647,12 @@ data Conversion
646647 = NoConversion
647648 | Conversion { mapKey :: Text , mapValue :: Text }
648649
650+ defaultConversion :: Conversion
651+ defaultConversion = Conversion
652+ { mapKey = " mapKey"
653+ , mapValue = " mapValue"
654+ }
655+
649656{-| Convert association lists to homogeneous maps
650657
651658 This converts an association list of the form:
Original file line number Diff line number Diff line change @@ -19,14 +19,15 @@ module Dhall.JSON.Yaml
1919import Data.ByteString (ByteString )
2020import Data.Monoid ((<>) )
2121import Data.Text (Text )
22- import Dhall.JSON (Conversion (.. ), SpecialDoubleMode (.. ), codeToValue )
22+ import Dhall.JSON (Conversion (.. ), SpecialDoubleMode (.. ))
2323import Options.Applicative (Parser )
2424
2525import qualified Data.Aeson
2626import qualified Data.Aeson.Yaml
2727import qualified Data.ByteString.Lazy
2828import qualified Data.Vector
2929import qualified Dhall
30+ import qualified Dhall.JSON
3031import qualified Options.Applicative
3132
3233data Options = Options
@@ -45,7 +46,7 @@ defaultOptions =
4546 , omission = id
4647 , documents = False
4748 , quoted = False
48- , conversion = NoConversion
49+ , conversion = Dhall.JSON. defaultConversion
4950 , file = Nothing
5051 , output = Nothing
5152 }
@@ -76,7 +77,7 @@ dhallToYaml Options{..} mFilePath code = do
7677
7778 let explaining = if explain then Dhall. detailed else id
7879
79- json <- omission <$> explaining (codeToValue conversion UseYAMLEncoding mFilePath code)
80+ json <- omission <$> explaining (Dhall.JSON. codeToValue conversion UseYAMLEncoding mFilePath code)
8081
8182 return $ jsonToYaml json documents quoted
8283
Original file line number Diff line number Diff line change 55module Main where
66
77import Data.Monoid ((<>) )
8- import Dhall.JSON (Conversion (.. ))
98import Test.Tasty (TestTree )
109
1110import qualified Data.Aeson as Aeson
@@ -67,12 +66,8 @@ testDhallToJSON prefix = Test.Tasty.HUnit.testCase prefix $ do
6766
6867 _ <- Core. throws (Dhall.TypeCheck. typeOf resolvedExpression)
6968
70- let mapKey = " mapKey"
71- let mapValue = " mapValue"
72- let conversion = Conversion {.. }
73-
7469 let convertedExpression =
75- Dhall.JSON. convertToHomogeneousMaps conversion resolvedExpression
70+ Dhall.JSON. convertToHomogeneousMaps Dhall.JSON. defaultConversion resolvedExpression
7671
7772 actualValue <- do
7873 Core. throws (Dhall.JSON. dhallToJSON convertedExpression)
Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ import Test.Tasty (TestTree)
1010
1111import qualified Data.ByteString
1212import qualified Data.Text.IO
13- import qualified Dhall.JSON
1413import qualified Dhall.JSON.Yaml
1514import qualified Dhall.Yaml
1615import qualified GHC.IO.Encoding
@@ -38,7 +37,6 @@ testTree =
3837 " ./tasty/data/emptyList"
3938 , testDhallToYaml
4039 Dhall.JSON.Yaml. defaultOptions
41- { conversion = Dhall.JSON. Conversion " mapKey" " mapValue" }
4240 " ./tasty/data/emptyMap"
4341 , Test.Tasty.ExpectedFailure. ignoreTestBecause " #1516" $
4442 testDhallToYaml
You can’t perform that action at this time.
0 commit comments