module Arion.Aeson where import Prelude () import Data.Aeson import qualified Data.ByteString.Lazy as BL import qualified Data.Text.Lazy as TL import qualified Data.Text.Lazy.Builder as TB import qualified Data.Aeson.Encode.Pretty import Data.Aeson.Encode.Pretty ( defConfig , confCompare , confTrailingNewline ) import Protolude pretty :: ToJSON a => a -> Text pretty :: forall a. ToJSON a => a -> Text pretty = Text -> Text TL.toStrict forall b c a. (b -> c) -> (a -> b) -> a -> c . Builder -> Text TB.toLazyText forall b c a. (b -> c) -> (a -> b) -> a -> c . forall a. ToJSON a => Config -> a -> Builder Data.Aeson.Encode.Pretty.encodePrettyToTextBuilder' Config config where config :: Config config = Config defConfig { confCompare :: Text -> Text -> Ordering confCompare = forall a. Ord a => a -> a -> Ordering compare, confTrailingNewline :: Bool confTrailingNewline = Bool True } decodeFile :: FromJSON a => FilePath -> IO a decodeFile :: forall a. FromJSON a => FilePath -> IO a decodeFile FilePath fp = do ByteString b <- FilePath -> IO ByteString BL.readFile FilePath fp case forall a. FromJSON a => ByteString -> Either FilePath a eitherDecode ByteString b of Left FilePath e -> forall a. HasCallStack => Text -> a panic (forall a b. ConvertText a b => a -> b toS FilePath e) Right a v -> forall (f :: * -> *) a. Applicative f => a -> f a pure a v