• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Aeson 2 malformed field in cross-module import when Strict pragma is enabled

Resolved: Aeson 2 malformed field in cross-module import when Strict pragma is enabled

0
By Isaac Tonny on 15/03/2023 Issue
Share
Facebook Twitter LinkedIn

In this post, we will see how to resolve Aeson 2 malformed field in cross-module import when Strict pragma is enabled

Question:

Please note that the issue described below doesn’t happen in aeson 1.4.7 (stack LTS-16.31). This could be something related to ghc 9.2.7 perhaps.
I have noticed that if I define a simple record in aeson and then import it, the record “code” tag is now malformed as “body” in encode output. It happens only when importing as a module.
First, a simple module Test1:
Now, if I import the module in ghci and encode Rsp – “code” tag is now encoded as “body” tag which appears twice instead of once:
I found this when debugging migration issues for migrating from aeson 1.4.7.1 (on ghc 8.8.4 via Stack LTS-16.31) to aeson 2.0.3.0 (on ghc 9.2.7 via Stack LTS-20.13). It doesn’t happen if instead of importing the module, I directly load Test1.hs code in ghci.
If I remove Strict pragma, the issue seems to go away. Perhaps something is going on here that is new to ghc 9.2+ or template haskell derivation in aeson?

Best Answer:

This is a bug that is already fixed in 2.1.1.0 as noted in changelog:

Use unsafeDupablePerformIO instead of incorrect accursedUnutterablePerformIO in creation of keys in TH serialisation. This fixes a bug in TH deriving, e.g. when Strict pragma was enabled.


So it seems any LTS that has aeson pre 2.1.1.0 is unusable if template haskell derivation is enabled for aeson which I suspect is the case for lot of us.

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com

aeson ghc haskell
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: linq2db throws exception when filtering by nested collection

02/04/2023

Resolved: Table data is coming as empty in React

02/04/2023

Resolved: In a Pinescript v5 Strategy why is my bool not working?

02/04/2023

Comments are closed.

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.