From 502aba6e76d18539eb702e67fed62ae90630aaf6 Mon Sep 17 00:00:00 2001 From: Greg Pfeil Date: Sun, 19 May 2024 22:21:16 -0600 Subject: [PATCH] Remove `null`s from generated JSON Fixes #39. --- library/Hpack/Dhall.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Hpack/Dhall.hs b/library/Hpack/Dhall.hs index 4e8e626..cea1ee2 100644 --- a/library/Hpack/Dhall.hs +++ b/library/Hpack/Dhall.hs @@ -48,7 +48,7 @@ import Dhall.Core (Expr) import Dhall.Parser (Src, exprFromText) import Dhall.Import (loadWith, emptyStatus) import Dhall.TypeCheck (typeOf) -import Dhall.JSON (dhallToJSON) +import Dhall.JSON (dhallToJSON, omitNull) import Dhall.Pretty (prettyExpr, layoutOpts) import qualified Prettyprinter as PP import qualified Prettyprinter.Render.Text as PP @@ -129,7 +129,7 @@ textToJson textToJson settings text = runExceptT $ do expr <- liftIO $ check settings text _ <- liftResult $ typeOf expr - liftResult $ ([],) <$> dhallToJSON expr + liftResult $ ([],) . omitNull <$> dhallToJSON expr where liftResult :: (Show b, Monad m) => Either b a -> ExceptT String m a liftResult = ExceptT . return . first show