Open MangoIV opened 1 year ago
I guess it's a bit more complicated because you'd have to carry along the labels split from the input type in a wrapper around Manipulation
I've tried at times to make a params
term that could be used in this type of situation but I never found a way to get it to work right to figure out the induction on type level natural numbers. For inlining there's inlineColumns
which might be used for similar purposes.
I don’t think going via the numbers is a good idea tbh. I don’t have a solution written out though so I can be wrong
Thank you for writing this library. It’s awesome. Compile times are of course ass (21s spent in the simplifier) but that’s just GHCs fault.
(this is actually hilarious)
class All KnownNat ixs
=> HasParams (ixs :: [Nat]) (params :: [NullType]) (tys :: [NullType]) where
parameters :: NP (TypeExpression db) tys -> NP (Expression grp lat with db from) tys
instance HasParams '[] params '[] where
parameters Nil = Nil
instance (HasParam ix params ty, HasParams ixs params tys)
=> HasParams (ix:ixs) params (ty:tys) where
parameters (ty :* tys) = parameter @ix @params ty :* parameters @ixs @params tys
params
:: forall ns tys lat with db params from grp
. (All (NullTyped db) tys, HasParameters ns params tys)
=> NP (Expression grp lat with db params from) tys
params = parameters @ns (hcpure (Proxy @(NullTyped db)) (nulltype @db))
Maybe we can do something built on this? Haven't checked it.
(Values_ (hmap ((`as` Alias) . Set) (params @'[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])))
what I'm trying to say is can we just have something like GManipulation
which instead of taking a list of NullType
takes a list of NullType
paired with their original name (as computed with the squeals rowtype type family) and then wrap around a Manipulation and then we can avoid the whole natural numbers stuff altogether?
so similarly to the Manipulation_
type family but it doesn't throw away the label types in the parameter list of NullType
passed to Manipulation
Sorry if that's a bit unclear, I haven't dug in too deep yet :D
thank you for your support!
Oh those label types aren't thrown away.
In my case the names are exactly like the ones specified with the overloaded labels so it should be possible to just get the values from the types in the input type?
Sure, you don't need to include the labels, #label
is just short for Alias @label
and the label
can be inferred by GHC so you can just use Alias
if you want, i.e. Set (param @1) `as` Alias :* Set (param @2) `as` Alias :* ...
The kind of the last type parameter of a QueryClause
is a ColumnsType
so includes column labels as well as optionalities (default value or not) in addition to NullType
s.
We cannot avoid natural numbers because these actually correspond to PostgreSQL positional parameter numbers.
Ah right that makes sense. Unfortunate. Well then we have to hack the natural numbers into place i guess
@MangoIV something I've done in my last workplace was to aggressively use schemas and multiple Schema.hs files to cut down on squeal compile times, might be worth a go.
Is there an intented way to express this generically?
In my case the names are exactly like the ones specified with the overloaded labels so it should be possible to just get the values from the types in the input type?