HeinrichApfelmus / threepenny-gui

GUI framework that uses the web browser as a display.
https://heinrichapfelmus.github.io/threepenny-gui/
Other
439 stars 77 forks source link

Remove the use of `Data.Aeson.Generic` and use GHC Generics instead. #71

Closed kfl closed 10 years ago

kfl commented 10 years ago

To get rid of the warnings from aeson about Data.Aeson.Generic being deprecated.

HeinrichApfelmus commented 10 years ago

Thanks a lot!

kfl commented 10 years ago

The issues should reopened. Because the fix broke the protocol between the server and the browser.

The reason is that genericToJSON encode sum types different from Data.Aeson.Generic.

For instance, Data.Aeson.Generic encode an instruction as:

{"RunJSFunction":"elidToElement(\"*2:canvas\").getContext('2d').fill()"}

Whereas genericToJSON encode it as:

{"contents":"elidToElement(\"*2:canvas\").getContext('2d').fill()","tag":"RunJSFunction"}

Unfortunately there does not seem to be a way to configure genericToJSON to behave like Data.Aeson.Generic.

HeinrichApfelmus commented 10 years ago

Ah, I see, thanks! And now I remember why I've put up with that warning instead of switching to Generics. :smile:

The correct way to solve this problem is to make an explicit instance of ToJSON, thus specifying the serialization format.

kfl commented 10 years ago

I think it might be cleaner to fix it in driver.js which I'm looking into right now.