beam
beam copied to clipboard
Is there any way to reuse a `ToField`, `FromField` definitions from sqlite-simple?
Beam uses sqlite-simple as a backend for SQLite database. I have some instances of classes ToField
and FromField
for sqlite-simple, which could convert my datatypes to sql field and vice versa.
However, it is unclear to me how I should write an instance of kind
instance ( Typeable a, FromField a ) => FromBackendRow Sqlite a where
...
instance ( ToField a ) => HasSqlValueSyntax Sqlite a where
...
Is there a way to define such instances?
I think for HasSqlValueSyntax
the following would be enough:
instance ( ToField a ) => HasSqlValueSyntax SqliteValueSyntax a where
sqlValueSyntax f = SqliteValueSyntax . emitValue $ toField f
Although, for some reason, my custom type does not become convertible with val_
even with the definition of this instance.
The FromBackendRow
is trickier because it involves conversion of errors.