Commit Graph

346 Commits

Author SHA1 Message Date
Shane O'Brien
db148ff18d
Simplify Labels 2021-05-05 15:04:59 +01:00
Shane O'Brien
cfe8a70a22
Don't try to cram ADT into Rel8able 2021-05-05 14:30:22 +01:00
Shane O'Brien
666f0b94a0
Try to fix compile error? 2021-05-05 12:16:48 +01:00
Shane O'Brien
d07e3b5cfc
Add and export missing constructors for MaybeTable and friends 2021-05-05 03:14:23 +01:00
Shane O'Brien
8a680c99c3
Reverse dependency between MaybeTable (and friends) and Serializable 2021-05-05 03:14:23 +01:00
Shane O'Brien
45f6f2b862
Rearrange parameters of ggaggregate 2021-05-05 03:14:22 +01:00
Shane O'Brien
cf8bdc7a0c
Add constructors for HKD 2021-05-05 03:14:22 +01:00
Shane O'Brien
7a526b6ec1
Generalize constructor functions in Rel8.Table.ADT to Rel8.Generic.Construction 2021-05-05 03:14:22 +01:00
Shane O'Brien
9fd885fc3f
Include both Apply and "Legacy" variants of aggregateADT 2021-05-05 03:14:22 +01:00
Shane O'Brien
845516adbd
Add constructADT, deconstructADT, nameADT, insertADT, aggregateADT to Rel8.Table.ADT 2021-05-05 03:14:22 +01:00
Shane O'Brien
2cdc3947e2
The guts of the new Generic construction machinery 2021-05-05 03:14:22 +01:00
Shane O'Brien
fab5b4e02d
Implement our own HKD in terms of the existing Generic machinery
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`.
2021-05-05 03:14:22 +01:00
Shane O'Brien
4bc16d3451
Introduce ADT meta-Rel8able for sum types 2021-05-05 03:14:22 +01:00
Shane O'Brien
23bb65b24b
Drop Encodes and litTable, they don't seem necessary 2021-05-05 03:14:22 +01:00
Shane O'Brien
fb3d2d9caf
Add EqTable and OrdTable instances for HKD 2021-05-05 03:14:22 +01:00
Shane O'Brien
6e42c1ea63
Unfold Rel8.Schema.HKD into Rel8.Generic.HKD and Rel8.Column.Lift 2021-05-05 03:14:22 +01:00
Shane O'Brien
95a2ebf5e0
Unfold Rel8.Schema.Field into Rel8.Column.* 2021-05-05 03:14:21 +01:00
Shane O'Brien
6ecc65faf4
Remove obsolete Rel8.Schema.Structure 2021-05-05 03:14:21 +01:00
Shane O'Brien
356d591c6c
Fold Rel8.Schema.Context.Result into Rel8.Schema.Context 2021-05-05 03:14:21 +01:00
Shane O'Brien
c8341c140f
Reverse dependency between Rel8.Schema.Context and Rel8.Schema.Result 2021-05-05 03:14:21 +01:00
Shane O'Brien
66dc44da33
Teach Table and friends about Sum types 2021-05-05 03:14:21 +01:00
Shane O'Brien
6c20afa21d
Add Rel8.Generic.Table.ADT 2021-05-05 03:14:21 +01:00
Shane
8cf243e721
Merge pull request #45 from circuithub/expose-array1d
Expose Array1D constructor
2021-04-30 13:16:03 +01:00
Shane O'Brien
e432f6d068
Split greify and gunreify out of GTable
There is actually nothing specific to `reify` in the `Generic` version of these operations, they're actually just a specific instance of a much more general `gmap` operation. This now lives in `Rel8.Generic.Map`.
2021-04-28 12:12:31 +01:00
Gary Pamparà
b2e2fc96df Expose Array1D constructor 2021-04-28 11:07:52 +02:00
Shane O'Brien
1c73ec6814
Add reify and unreify to Table class
Previously these were implemented with `unsafeCoerce`, which was mostly correct, but was incorrect for certain instances of `HList`. With this change, `deriving Rel8able` will now fail to type check in those instances.
2021-04-27 17:04:40 +01:00
Shane O'Brien
1276bebbb0
Use FCF to decouple GTable from Table 2021-04-27 17:04:40 +01:00
Oliver Charles
3e8f632cd1 Rough documentation for constructing orderings 2021-04-24 22:30:13 +01:00
Shane O'Brien
26ccab33c8
Change arguments to listAggWithOrder 2021-04-23 11:22:33 +01:00
Shane O'Brien
5160431df3
Add ability to specify ordering with list aggregations 2021-04-22 15:48:46 +01:00
Ollie Charles
675dc60a24 Correct encoders for Infinity, -Infinity and NaN
Fixes #43
2021-04-22 11:14:15 +01:00
Shane O'Brien
93638f8bdf
Export Composite and Enum 2021-04-18 22:30:31 +01:00
Shane O'Brien
7c4c6ff930
Add Enum and Composite deriving via helpers 2021-04-18 21:34:50 +01:00
Shane O'Brien
b8ff282b10
Add instances for 6 and 7 tuples (after all, they're free now)
We stop at 7 though because even GHC doesn't provide Generic instances for 8-tuples and beyond.
2021-04-18 16:48:16 +01:00
Shane O'Brien
fb2107513e
Add better generic deriving for EqTable, OrdTable and ToExprs
This builds upon the `Rel8.Generic.Record` machinery introduced in the previous commit. It means that we can use generic implementations of the `Table`, `EqTable`, `OrdTable` and `ToExprs` for all tuple types, rendering `HPair`, `HTrio`, `HQuartet` and `HQuintet` unnecessary (this commit removes them).
2021-04-18 16:35:48 +01:00
Shane O'Brien
6d3959e9b0
Allow generic deriving of Table instances for non-record types
The is implemented using new machinery in `Rel8.Generic.Record`, which transforms the generic representation of any type to be as if that type was a record. Numeric labels are assigned to anonymous field selectors like `_1`, `_2`, `_3` and so on.
2021-04-18 00:52:15 +01:00
Shane O'Brien
6ca25e57dd
Add generic default for Table class, and share its implementation with Rel8able 2021-04-16 15:36:35 +01:00
Shane O'Brien
47e7842c0f
Sketch of HKD-lifting of Generic types 2021-04-16 15:17:39 +01:00
Oliver Charles
242dc79996 Add and export KRel8able 2021-04-16 13:25:52 +01:00
Shane O'Brien
04fdf2732d
Make Rel8able have kind ((X -> Type) -> Type) -> Constraint
Previous it was `((Type -> Type) -> Type) -> Constraint`. The problem is this clashes with things like `HKD` from `higgledy`. We can use GADTs and PolyKinds hacks to get around this while mostly retaining the same API. The only major difference is we use `Result` in places where we used `Identity` before.
2021-04-15 17:00:12 +01:00
Shane O'Brien
f6a9c968e4
Fix array1DAggExpr 2021-04-15 13:42:17 +01:00
Shane O'Brien
ba684c0585
Export Array1D 2021-04-14 20:15:47 +01:00
Shane O'Brien
b0e605305a
Add array1DAggExpr 2021-04-14 19:50:11 +01:00
Ollie Charles
e52dd759b9 Exports to allow users to define Table themselves 2021-04-14 13:11:52 +01:00
Shane O'Brien
2283f03bd2
Restore HTable superclass to Rel8able 2021-04-14 08:11:15 +01:00
Shane O'Brien
11a22291ab
Simplify Column type family
Now that the Field type family only needs a Necessity and a Type, we don't need to "parse" the Type to find the Necessity, we can instead just make it so that Column creates a Required field, and repurpose the name Default to be a type family that creates an Optional field.

The previous "parsing" approach was brittle sometimes, particularly in the case of polymorphism.
2021-04-14 07:25:39 +01:00
Shane O'Brien
5e4df5096c
Complete overhaul of Rel8.Schema.Generic 2021-04-13 21:35:37 +01:00
Shane O'Brien
09e449bc48
Fix typo in createView 2021-04-13 21:23:09 +01:00
Ollie Charles
ef91171265 Document LEFT JOINs 2021-04-11 12:48:46 +01:00
Ollie Charles
895e5fdc76 Document inner joins 2021-04-11 12:41:55 +01:00