yesodweb / yesodweb/persistent
Invert control for deriving instances
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 486
- Forks
- 306
- PR merge metrics
- No merged PRs in 30d
Description
Hello there. The MkPersistSettings feature is handy for controlling the generation of the Persistent entities and their instances. There is a field that has this type:
mpsDeriveInstances :: MkPersistSettings -> [Name]
Given some list of Names of classes, this will spit out instance derivations of each class for both the keys and entities with an implicit strategy.
This is useful, but it's a bit of a blunt instrument. Sometimes you want one set of classes for the keys and another for the entities. Sometimes you want to derive class A using one strategy and class B using another. Sometimes you want to derive stuff (or even decide whether to derive stuff) by inspecting the relevant types.
In general, I feel like it'd be more flexible to provide something like:
data EntityParts = EntityParts { epEntity :: Dec, epKey :: Dec }
mpsDeriveThings :: MkPersistSettings -> (EntityParts -> Q [Dec])
Then the user can decide what to do for each entity and each of its associated data family instances.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating MkPersistSettings and the existing mpsDeriveInstances implementation, then trace how derived declarations are generated for keys and entities. Compare that flow with the proposed EntityParts and mpsDeriveThings interfaces; done means supporting separate, type-aware derivation decisions for each entity and its associated data family instances.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100