{- Render a `JSON` value as `Text` This is useful for debugging `JSON` values or for tests. For anything more sophisticated you should use `dhall-to-json` or `dhall-to-yaml` -} let JSON = ./core.dhall sha256:22ba363a8622642e788ffdd8fb98e5a51b1be8ebfcbefe2853e74932078a60af ? ./core.dhall let Text/concatMapSep = ../Text/concatMapSep sha256:c272aca80a607bc5963d1fcb38819e7e0d3e72ac4d02b1183b1afb6a91340840 ? ../Text/concatMapSep let render : JSON.Type → Text = λ(j : JSON.Type) → j Text { string = λ(x : Text) → Text/show x , number = λ(x : Double) → Double/show x , object = λ(x : List { mapKey : Text, mapValue : Text }) → let body = Text/concatMapSep "," { mapKey : Text, mapValue : Text } ( λ(e : { mapKey : Text, mapValue : Text }) → " ${Text/show e.mapKey}: ${e.mapValue}" ) x in "{${body} }" , array = λ(x : List Text) → let body = Text/concatMapSep "," Text (λ(y : Text) → " ${y}") x in "[${body} ]" , bool = λ(x : Bool) → if x then "true" else "false" , null = "null" } let example0 = assert : render ( JSON.array [ JSON.bool True , JSON.string "Hello" , JSON.object [ { mapKey = "foo", mapValue = JSON.null } , { mapKey = "bar", mapValue = JSON.number 1.0 } ] ] ) ≡ "[ true, \"Hello\", { \"foo\": null, \"bar\": 1.0 } ]" in render