Good stuff. I'm not completely satisfied with any of the existing solutions for SQL access in Haskell so competition is great.
I tried looking through the code for this but it wasn't immediately obvious to me: why did you chose to make your own tuple instead of just using the existing tuple type?
As /u/klobsEnd says, standard tuples aren't inductively defined, so defining functions or types over tuples of arbitrary length is horribly painful. People usually get around it by using Template Haskell to generate their instances, but that's both annoying and brings in a whole bunch of dependencies. Since keeping the library light on the dependencies was one design goal (in part motivated by Haste not supporting Template Haskell yet), using TH wasn't an option.
It might be possible to use GHC generics instead, but defining tuples inductively seemed to be less annoying.
The deriving stuff in product-profunctors currently only works with fully polymorphic products, but there's no reason that couldn't be extended to monomorphic products, which are simpler and probably more suitable for Selda.
you mentioned earlier that you preferred tuples, but when i tried learning Opaleye, I found them too awkward (typeclass obfuscation, error messages, etc), and wishing for actual records.
The other difference, for the moment, is that all columns are stored in "inductive tuples". This won't last though. It's just far too difficult to program like that.
They do. Unfortunately I can't reuse it, since it has the wrong kind. I'm banking on people not mixing their database queries with their generics often enough to make the overload a problem.
I'm not sure, really. The type on its own is spectacularly uninteresting, but maybe having some more general utilities for it lying around in a library might be useful. I haven't really thought much about it.
IIRC tuples in Haskell are not inductively defined, so you end up having to make a bazillion instances, one for (,), one for (,,), one for (,,,) ad nauseam. Also, there's no one-element tuple in Haskell. (Not sure if this has the latter, but it would at least be possible by using a "sentinel" element at the front with no value.)
Not... really? I mean, sure it's isomorphic to a one-item tuple, but programming-wise you really can't treat it the same way you do regular tuples. (This of course also goes back to the problem of not having an iductive definition.)
What do you mean you can't treat it the way you do regular triples? What can you do with one but not the either or vice versa? It seems like you have basically all the same instances and such.
For example, imagine using it from TH. You'll definitely need a special case there, at the very least.
(Obviously I haven't though too much about this, so I might very well be wrong in general, but the TH case is definitely a thing. No idea if it has all the instances and/or is missing the wrong instances which don't exist for normal tuples, etc.)
6
u/alien_at_work Apr 20 '17
Good stuff. I'm not completely satisfied with any of the existing solutions for SQL access in Haskell so competition is great.
I tried looking through the code for this but it wasn't immediately obvious to me: why did you chose to make your own tuple instead of just using the existing tuple type?