diff options
author | Profpatsch <mail@profpatsch.de> | 2023-08-06T10·46+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-08-06T11·17+0000 |
commit | 1fd59f51580244bac8e75b4c08f103daa20674d9 (patch) | |
tree | 701df9da2d8ff52f7c881e221b416472b0988be3 /users/Profpatsch/mailbox-org/src/AesonQQ.hs | |
parent | ce4acc08a53fca8bc00282ca0eb4ca5fc048a222 (diff) |
chore(users/Profpatsch): clean up haskell libs a little r/6464
Change-Id: Ia9a6c5a754ca8f2912308feb5a26f5276a08d24c Reviewed-on: https://cl.tvl.fyi/c/depot/+/9011 Reviewed-by: Profpatsch <mail@profpatsch.de> Autosubmit: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI
Diffstat (limited to 'users/Profpatsch/mailbox-org/src/AesonQQ.hs')
-rw-r--r-- | users/Profpatsch/mailbox-org/src/AesonQQ.hs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/users/Profpatsch/mailbox-org/src/AesonQQ.hs b/users/Profpatsch/mailbox-org/src/AesonQQ.hs new file mode 100644 index 000000000000..2ac3d533aeaa --- /dev/null +++ b/users/Profpatsch/mailbox-org/src/AesonQQ.hs @@ -0,0 +1,24 @@ +{-# LANGUAGE TemplateHaskellQuotes #-} + +module AesonQQ where + +import Data.Aeson qualified as Json +import Language.Haskell.TH.Quote (QuasiQuoter) +import PossehlAnalyticsPrelude +import PyF qualified +import PyF.Internal.QQ qualified as PyFConf + +aesonQQ :: QuasiQuoter +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 + |] + } |