yesodweb / yesodweb/persistent

Cannot turn off PathPiece and ToHttpApiData newtype instances for keys

Open
#1,458 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haskell
Stars
486
Forks
306
PR merge metrics
No merged PRs in 30d

Description

Hi!

I'm writing a not-a-webapp and I think it's somewhat odd that Persistent will generate deriving newtype instance FromHttpApiData and likewise for PathPiece for all keys, even though this should not be necessary for non-web users; furthermore there is a mechanism in MkPersistSettings to set mpsDeriveInstances to derive more instances, which could be used to achieve this for web users that want it.

I think that the default mkPersistSettings should probably be changed to include these extra instances, such that it can be overridden if they are not desirable. This would unfortunately be a breaking change for those overriding mpsDeriveInstances while discarding the default value (which was previously empty-list).

https://github.com/yesodweb/persistent/blob/7222127f812edd51c0de7f5dbc0121c80aacd444/persistent/Database/Persist/TH.hs#L1748-L1750

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in persistent/Database/Persist/TH.hs around lines 1748-1750 and inspect how mkPersistSettings populates mpsDeriveInstances. Confirm how the default PathPiece and FromHttpApiData instances are generated and define the configuration behavior that lets non-web users disable them while web users can retain them. Done means the defaults and override behavior match the requested use cases without silently discarding intended derivations.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.