Closed echatav closed 2 years ago
Is #.
necessary or can we use scrap-your-nils?
Is
#.
necessary or can we use scrap-your-nils?
No because the inference constraint on Aliasable
, GHC explains the problem:
> • Illegal instance declaration for
> ‘Aliasable fld (x -> x0) (EncodeParams db '[fld ::: ty] x)’
> The liberal coverage condition fails in class ‘Aliasable’
> for functional dependency: ‘aliased -> expression’
> Reason: lhs type ‘EncodeParams db '[fld ::: ty] x’
> does not determine rhs type ‘x -> x0’
> Un-determined variable: x0
Squeal had combinators for hand rolling
FromPG
instances forPGenum
s andPGcomposite
s. This PR adds combinators for hand rollingToPG
instances. To do this it loosens theEncodeParams
type to be polykindednewtype EncodeParams (db :: SchemasType) (tys :: [k]) (x :: Type)
. The type variabletys
can be a list of any kind, where before it was[NullType]
. We need to instantiate it for one other list,RowType
. Then we define the following combinator to use theseRowType
d parameter encodings to definetoPG
methods.To construct
RowType
d parameter encodings, we can use some old combinators likenilParams
andappendParams
but the rest like.*
,*.
andgenericParams
will be useless since they don't address field names. So similar combinators.#
,#.
andgenericRowParams
are provided.Additionally, a combinator is provided to define
toPG
forPGenum
s.