parsonsmatt · GitHub

parsonsmatt

approved these changes Jan 6, 2021

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.

@ivanbakel

@ivanbakel

The Compatible modules are now elided for old GHC versions.
The RawSQLite compatibility instances are now polyfilled manually for
old enough versions of `base`.

@ivanbakel

@parsonsmatt

vapaj pushed a commit to KSF-Media/persistent that referenced this pull request

Mar 10, 2021
…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`.

Read the original on github.com ↗