haskell-beam / beam

A type-safe, non-TH Haskell SQL library and ORM
https://haskell-beam.github.io/beam/
577 stars 170 forks source link

Add type for returning arbitrary size tuples #450

Open mightybyte opened 4 years ago

mightybyte commented 4 years ago

The postgresql-simple library has a type :. that facilitates returning query results of arbitrary size.

https://hackage.haskell.org/package/postgresql-simple-0.6.2/docs/Database-PostgreSQL-Simple.html#t:Only

(I didn't link to :. because GitHub doesn't handle it properly)

Could something similar be added to beam? I'm not stuck on :. as the operator. Servant has a :. operator that conflicts, so I'm open to anything. But the convenience would be really nice.

kmicklas commented 4 years ago

You should effectively be able to do this already by nesting tuples. @mightybyte Are there any benefits to a specific type for this that I'm missing?

mightybyte commented 4 years ago

Nesting tuples is just a pain. Also, when I was playing with it I believe there was a mismatch between the size of tuples that were actually supported compared with what the documentation said. An operator like this is purely for convenience.

kmicklas commented 4 years ago

Yeah, I guess having an operator with associativity is nice because you don't have to write out the nesting structure. PRs welcome!

3noch commented 4 years ago

Is there a library that provides this type? It seems like something that doesn't need to be rebuilt.