yesodweb / persistent

Persistence interface for Haskell allowing multiple storage methods.
MIT License
467 stars 297 forks source link

Derive `{From,To}JSON` for `EntityDef` #1540

Open evanrelf opened 4 months ago

evanrelf commented 4 months ago

...and its dependencies.

Motivated by some orphan instances we have at $WORK to dump our persistent entities (i.e. our database schema) to JSON for manipulation elsewhere.

evanrelf commented 4 months ago

Not sure if you want @since annotations on Generic, FromJSON, and ToJSON, so I've omitted them for now.

evanrelf commented 4 months ago

Not sure that upstream wants this, but I'm interested in building stuff with this at work, so maybe others would find it useful.

evanrelf commented 4 months ago

I'm a little hesitant to incorporate this, because it sort of makes the JSON representation part of the public API.

Yeah, I figured it wouldn't be a 100% uncontroversial change! So I don't mean to push for this strongly if you or other maintainers feel it's not the right move.