-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for composite types #246
Comments
@LukaHorvat is this a solution for #238, too? |
Nope, this is only for the fully typed ones. The parser should work for untyped records as well but there's an issue with calling the individual field parsers. You need to provide the runtime representation of the parsed type and you don't have that available. |
And for instance FieldRenderers ts => ToField (Composite ts) where
toField = pgCompositeFieldRenderer
pgCompositeFieldRenderer
:: FieldRenderers ts => Composite ts -> Action
pgCompositeFieldRenderer c =
Many $ [ Plain "row(" ] ++
intersperse (Plain ",") (renderCompositeFields c) ++
[ Plain ")" ]
class FieldRenderers ts where
renderCompositeFields :: Composite ts -> [Action]
instance FieldRenderers '[] where
renderCompositeFields _ = []
instance (ToField t, FieldRenderers ts) => FieldRenderers (t ': ts) where
renderCompositeFields (t :& ts) = toField t : renderCompositeFields ts might do the trick? |
@LukaHorvat I'm interested in adding support for anonymous/untyped records. Could you give me a clue where your implementation would need to change to support them? |
It's been a while so I'm not sure, but I think |
I'm opening this issue to track support for composite types. Here's what I have so far.
This needs to be tested but it seems to work for simple cases. Perhaps it can be improved and merged into the library or at the very least it might save someone some effort.
The text was updated successfully, but these errors were encountered: