diff --git a/dhall-json/dhall-json.cabal b/dhall-json/dhall-json.cabal index 6df7c9560..aa1a2f14b 100644 --- a/dhall-json/dhall-json.cabal +++ b/dhall-json/dhall-json.cabal @@ -39,7 +39,7 @@ Library Build-Depends: base >= 4.11.0.0 && < 5 , aeson >= 1.4.6.0 && < 2.1 , - aeson-pretty < 0.9 , + aeson-pretty >= 0.8.0 && < 0.9 , aeson-yaml >= 1.1.0 && < 1.2 , bytestring < 0.12, containers >= 0.5.9 && < 0.7 , diff --git a/dhall-json/dhall-to-json/Main.hs b/dhall-json/dhall-to-json/Main.hs index 82c19ae9d..afccca408 100644 --- a/dhall-json/dhall-to-json/Main.hs +++ b/dhall-json/dhall-to-json/Main.hs @@ -1,5 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TypeApplications #-} module Main where @@ -12,14 +13,15 @@ import Options.Applicative (Parser, ParserInfo) import qualified Control.Exception import qualified Data.Aeson -import qualified Data.Aeson.Encode.Pretty +import qualified Data.Aeson.Text +import qualified Data.Aeson.Encode.Pretty as Pretty import qualified Data.ByteString.Lazy -import qualified Data.Text.IO as Text.IO +import qualified Data.Text.IO as Text.IO import qualified Dhall import qualified Dhall.JSON import qualified GHC.IO.Encoding -import qualified Options.Applicative as Options -import qualified Paths_dhall_json as Meta +import qualified Options.Applicative as Options +import qualified Paths_dhall_json as Meta import qualified System.Exit import qualified System.IO @@ -123,14 +125,18 @@ main = do Options {..} -> handle $ do - let config = Data.Aeson.Encode.Pretty.Config - { Data.Aeson.Encode.Pretty.confIndent = Data.Aeson.Encode.Pretty.Spaces 2 - , Data.Aeson.Encode.Pretty.confCompare = compare - , Data.Aeson.Encode.Pretty.confNumFormat = Data.Aeson.Encode.Pretty.Generic - , Data.Aeson.Encode.Pretty.confTrailingNewline = False } + let custom scientific = + Data.Aeson.Text.encodeToTextBuilder (Data.Aeson.Number scientific) + + let config = Pretty.Config + { Pretty.confIndent = Pretty.Spaces 2 + , Pretty.confCompare = compare + , Pretty.confNumFormat = Pretty.Custom custom + , Pretty.confTrailingNewline = False + } let encode = if pretty - then Data.Aeson.Encode.Pretty.encodePretty' config + then Pretty.encodePretty' config else Data.Aeson.encode let explaining = if explain then Dhall.detailed else id