This means that users defining new `DBType`s will have to additionally derive `Encodable` (but a simple `deriving Encodable` will suffice).
It also opens up the possibility of users defining non-`DBType`s that are `lit`able (and `select`able). For example, the `HKDT` helper makes allows arbitrary products of `DBType`s to be `lit`ed via `higgled`'s `HKD`:
```haskell
data S3Object = S3Object
{ bucketName :: Text
, objectKey :: Text
}
deriving stock Generic
deriving Encodable via HKDT S3Object
```
With the above loaded into GHCi:
```
>>> :t lit (S3Object mempty mempty)
lit (S3Object mempty mempty)
:: HKD S3Object Expr
```
The implementation is extensible, allowing for the possibility of other "strategies" (in addition to `DBType` and `HKD`) in the future.
To implement the `DBType` instance for `[]`, we wrapped the underlying Postgres array with `ROW()`. This is to allow nesting `[]` inside `[]` (Postgres treats a bare `foo[][]` as a multidimensional array).
However, instead of unconditionally wrapping the list itself with `ROW()`, we could instead wrap individual list elements. And even better, we can wrap them *conditionally*, i.e., only if they have an array type (e.g., `foo[]`). This makes our lists much closer to Postgres arrays, and eliminates the need for `Array1D`. It also means our lists can be concatenated with a bare `||` operator; no need for the flaky `(foo).f1` unwrapping step.
This `HKD` is a better fit for `Rel8` than `higgledy`'s `HKD`. In a very literal sense, this `HKD` is now a `Rel8able` (i.e., `Context -> Type`), whereas `higgledy`'s is `(Type -> Type) -> Type`. This meant we had to use hacks like `HKD a (Compose Aggregate Expr)` to get a `HKD` into the `Aggregate` context (and similarly for `Insert`). Now we can just do `HKD a Aggregate` and `HKD a Insert` like any other `Rel8able`.
Like `higgledy`'s, our `HKD` is compatible with `generic-lens`.
One feature we have that `higgledy` doesn't is the ability to support sum types. You can make a `HKD` out of an arbitrary algebraic data type (whose fields are `DBType`s).
What's still missing is constructor/deconstructor machinery, but that's nearly finished, and the underlying machinery will also be used by the `ADT` `Rel8able`.