module Data.Aeson.Extended where
import Data.Aeson (ToJSON)
import qualified Data.Aeson.Encode.Pretty as AesonPretty
import qualified Data.ByteString.Lazy as BL
encodeFilePretty :: (ToJSON a) => FilePath -> a -> IO ()
encodeFilePretty :: FilePath -> a -> IO ()
encodeFilePretty FilePath
fp = FilePath -> ByteString -> IO ()
BL.writeFile FilePath
fp (ByteString -> IO ()) -> (a -> ByteString) -> a -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Config -> a -> ByteString
forall a. ToJSON a => Config -> a -> ByteString
AesonPretty.encodePretty' Config
config
where
config :: Config
config =
Config
AesonPretty.defConfig
{ confTrailingNewline :: Bool
AesonPretty.confTrailingNewline = Bool
True,
confCompare :: Text -> Text -> Ordering
AesonPretty.confCompare = Text -> Text -> Ordering
forall a. Ord a => a -> a -> Ordering
compare
}