valderman / selda

A type-safe, high-level SQL library for Haskell
https://selda.link
MIT License
478 stars 58 forks source link

Does Selda support sum types with non-nullary constructors? #158

Closed H2CO3 closed 3 years ago

H2CO3 commented 3 years ago

Hi,

The title says it all. I've been reading various kinds of docs and tutorials about Selda for some time, but I couldn't come to a definitive answer as to whether it supports sum types with associated data. (This is not a feature request, I'm just curious.)

Thanks!

valderman commented 3 years ago

Not out of the box, unfortunately. You can add support for specific sum types by creating SqlType instances for them, provided that you can express all values of your type as one of the existing primitive types (a string or blob, for instance). This can be a bit clunky though, especially if you want to access the associated data in a query since you'd have to write the functionality to extract it yourself.

H2CO3 commented 3 years ago

Thanks for the quick reply, that explains it.