tvl-depot/users/Profpatsch/mailbox-org/AesonQQ.hs
Profpatsch 8c4730c433 chore(users/Profpatsch/*): more cabal maintenance
Change-Id: Ib1714abce2815873eb50dbeac088e812fa9098ab
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8686
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
Autosubmit: Profpatsch <mail@profpatsch.de>
2023-07-13 23:03:09 +00:00

23 lines
676 B
Haskell

{-# LANGUAGE TemplateHaskellQuotes #-}
module AesonQQ where
import Data.Aeson qualified as Json
import Data.Either qualified as Either
import PossehlAnalyticsPrelude
import PyF qualified
import PyF.Internal.QQ qualified as PyFConf
aesonQQ =
PyF.mkFormatter
"aesonQQ"
PyF.defaultConfig
{ PyFConf.delimiters = Just ('|', '|'),
PyFConf.postProcess = \exp -> do
-- TODO: this does not throw an error at compilation time if the json does not parse
[|
case Json.eitherDecodeStrict' @Json.Value $ textToBytesUtf8 $ stringToText $(exp) of
Left err -> error err
Right a -> a
|]
}