# Call for Beta Testers: New Flag \`-fdiagnostics-as-json\`

**URL:** <https://discourse.haskell.org/t/call-for-beta-testers-new-flag-fdiagnostics-as-json/8772>\
**Category:** Announcements\
**Created:** [February 11, 2024, 1:04am UTC](https://discourse.haskell.org/t/call-for-beta-testers-new-flag-fdiagnostics-as-json/8772 "2024-02-11T01:04:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![benbellick](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/benbellick/32/3224_2.png) [@benbellick](https://discourse.haskell.org/u/benbellick)\
**Post date:** [February 11, 2024, 1:04am UTC](https://discourse.haskell.org/t/call-for-beta-testers-new-flag-fdiagnostics-as-json/8772/1 "2024-02-11T01:04:55Z")

</div>

Hey everyone,

I wanted to share the addition of a new GHC flag to help users more easily parse diagnostic information. This is meant to ultimately replace the usage of `-ddump-json`. It was merged into master ~1 month ago.  
If you have already added the [nightlies channel to your ghcup](https://gitlab.haskell.org/ghc/ghc/-/wikis/GHC-status#2-ghc-nightlies), then you can find it in the release e.g. 9.9.20240208 by performing:

```haskell
> ghcup install ghc 9.9.20240208
> ghcup set ghc 9.9.20240208

```

Here is an example possible output:  
`> ghc bad.hs -fdiagnostics-as-json`

```haskell
[1 of 1] Compiling Bad ( ../tmp/bad.hs, ../tmp/bad.o )
{"version":"1.0","ghcVersion":"ghc-9.9.20230817","span":{"file":"bad.hs","start":{"line":9,"column":3},"end":{"line":9,"column":14}},"severity":"Error","code":88464,"message":["Variable not in scope: printLineas :: String -> IO a1"],"hints":[]}
{"version":"1.0","ghcVersion":"ghc-9.9.20230817","span":{"file":"bad.hs","start":{"line":10,"column":3},"end":{"line":10,"column":9}},"severity":"Error","code":88464,"message":["Variable not in scope: blaksh :: String -> IO ()"],"hints":[]}

```

The idea is to make it easier for external tools to parse error messages to make them easier to use. You can see the PR discussed [here](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/11093). You can see the JSON schema that the output data will conform to [here](https://gitlab.haskell.org/ghc/ghc/-/blob/master/docs/users_guide/diagnostics-as-json-schema-1_0.json?ref_type=heads) (it is also hyperlinked to in the compiler flags section of the docs.

Please try it out on an array of errors via the `-fdiagnostics-as-json` flag and let us know what you think! Thanks a ton 🙂

---

<div class="post-metadata">

**Author:** ![suzzr0](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/suzzr0/32/3226_2.png) [@suzzr0](https://discourse.haskell.org/u/suzzr0)\
**Post date:** [February 11, 2024, 2:09pm UTC](https://discourse.haskell.org/t/call-for-beta-testers-new-flag-fdiagnostics-as-json/8772/2 "2024-02-11T14:09:40Z")

</div>

Awesome work Ben congratulations on getting this merged 😄! Really excited to try this out for static-ls. Out of curiosity what’s the best place to provide any feedback if we have any?

---

<div class="post-metadata">

**Author:** ![taylorfausak](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/taylorfausak/32/54_2.png) [@taylorfausak](https://discourse.haskell.org/u/taylorfausak)\
**Post date:** [March 10, 2025, 2:09am UTC](https://discourse.haskell.org/t/call-for-beta-testers-new-flag-fdiagnostics-as-json/8772/3 "2025-03-10T02:09:36Z")

</div>

Sorry to resurrect such an old thread! Is this a reasonable place to provide feedback about this feature? I recently added support for `-fdiagnostics-as-json` to Purple Yolk, my Haskell extension for VSCode:

> <https://github.com/tfausak/purple-yolk/pull/100>
>
> Fixes #61.

It was mostly painless except for one thing: Now diagnostics go to STDERR but “compiling” messages go to STDOUT. Usually the “compiling” message can be used to clear diagnostics. But it seems like the order is no longer guaranteed. Sometimes I get a “compiling” message first, like before, but sometimes I get a diagnostic first. For example:

```haskell
[60 of 64] Compiling Main ( /Volumes/nvme/Developer/haskell-packages/cabal-gild/source/test-suite/Main.hs, interpreted )[cabal-gild-1.5.0.3-inplace-cabal-gild-test-suite]
{"version":"1.1","ghcVersion":"ghc-9.12.1","span":{"file":"/Volumes/nvme/Developer/haskell-packages/cabal-gild/./source/library/CabalGild.hs","start":{"line":11,"column":1},"end":{"line":11,"column":8}},"severity":"Warning","code":40910,"message":["Defined but not used: `warning'"],"hints":[],"reason":{"flags":["unused-top-binds"]}}
[61 of 64] Compiling CabalGild ( /Volumes/nvme/Developer/haskell-packages/cabal-gild/source/library/CabalGild.hs, interpreted )[cabal-gild-1.5.0.3-inplace]

```

Note that I get a diagnostic from the `CabalGild` module before I get the “compiling” message about starting to compile that module. This makes collecting diagnostics more difficult because I need to clear them when the module is recompiled.

---

<div class="post-metadata">

**Author:** ![mchav](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mchav/32/5143_2.png) [@mchav](https://discourse.haskell.org/u/mchav)\
**Post date:** [June 23, 2026, 11:11pm UTC](https://discourse.haskell.org/t/call-for-beta-testers-new-flag-fdiagnostics-as-json/8772/4 "2026-06-23T23:11:21Z")

</div>

Just discovered this! It’s exactly what I’ve needed for some time now. Thanks for this work. Perfect on GHCi too.
