Add newtype, TH functions for deriving instances from backend compat#1179
Add newtype, TH functions for deriving instances from backend compat#1179parsonsmatt merged 4 commits intoyesodweb:masterfrom
Conversation
parsonsmatt
left a comment
There was a problem hiding this comment.
This is awesome! Just one style question.
I'd like to batch this up with 2.12, but I can also release as 2.12.1 if you can't get to it soon.
Thanks!
| ( Compatible(..) | ||
| , makeCompatibleInstances | ||
| , makeCompatibleKeyInstances | ||
| ) where |
There was a problem hiding this comment.
Can we stick with 4 space indentation here? I know the codebase isn't consistent, but I want to get it moving in that direction. Thanks!
There was a problem hiding this comment.
Sure! Is it just the first indent that's 4-space, and should I convert the other files to it as well? I couldn't find a clear example in the codebase.
There was a problem hiding this comment.
Don't worry about converting anything old, but anything new should be 4 space. Thanks!
There was a problem hiding this comment.
Alright, I hope that's done correctly.
If a backend is compatible with another, it has a lot of obvious instances for various Persistent classes in terms of the backend it is compatible with - RawSqlite in the codebase is one example. This adds a newtype, Compatible, which has these compatible instances declared on it. Compatible is designed to be used with DerivingVia to automatically yield these compatible instances when given a witness of backend compatibility. To help use Compatible and write all the standalone derivations necessary to get a fully-featured compatible backend, this also adds some TH invocations to generate the standalone derivations for a given pair of compatible backend types. RawSqlite is rewritten to dogfood on thes invocations, to prove their effectiveness and simplify the code somewhat.
de8763f to
12acb1a
Compare
|
This build failure is interesting - the new code doesn't really make sense to have on old GHC versions, since if you don't have |
d95a082 to
2c80b2a
Compare
The Compatible modules are now elided for old GHC versions. The RawSQLite compatibility instances are now polyfilled manually for old enough versions of `base`.
2c80b2a to
ca54341
Compare
|
Alright, sorry for the delay in fixing this, but it should now work across all the supported GHC versions. The instances get polyfilled for older GHCs which don't have |
|
Sorry took me so long! LGTM, thanks so much 😄 |
…esodweb#1179) * Add newtype, TH functions for deriving instances from backend compat If a backend is compatible with another, it has a lot of obvious instances for various Persistent classes in terms of the backend it is compatible with - RawSqlite in the codebase is one example. This adds a newtype, Compatible, which has these compatible instances declared on it. Compatible is designed to be used with DerivingVia to automatically yield these compatible instances when given a witness of backend compatibility. To help use Compatible and write all the standalone derivations necessary to get a fully-featured compatible backend, this also adds some TH invocations to generate the standalone derivations for a given pair of compatible backend types. RawSqlite is rewritten to dogfood on thes invocations, to prove their effectiveness and simplify the code somewhat. * Add Changelong, since declarations * Fix indentation in Compatible.* modules * Make Database.Persist.Compatible backwards-compatible The Compatible modules are now elided for old GHC versions. The RawSQLite compatibility instances are now polyfilled manually for old enough versions of `base`.
If a backend is compatible with another, it has a lot of obvious instances for various Persistent classes in terms of the backend it is compatible with -
RawSqlitein the codebase is one example.This adds a newtype,
Compatible, which has these compatible instances declared on it.Compatibleis designed to be used withDerivingViato automatically yield these compatible instances when given a witness of backend compatibility.To help use
Compatibleand write all the standalone derivations necessary to get a fully-featured compatible backend, this also adds some TH invocations to generate the standalone derivations for a given pair of compatible backend types.RawSqliteis rewritten to dogfood on thes invocations, to prove their effectiveness and simplify the code somewhat.Before submitting your PR, check that you've:
@sincedeclarations to the HaddockAfter submitting your PR:
(unreleased)on the Changelog