[Haskell-cafe] [ANN] relational-record - relational-algebraic query building DSL

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Wed Dec 17 17:36:30 UTC 2014

On Wed, Dec 17, 2014 at 07:04:12PM +0200, Riivo Kolka wrote:
> On 14 December 2014 at 18:52, Manuel Gómez <targen at gmail.com> wrote:
> > Congratulations on the release!  It’s great to see more and more
> > interesting abstractions for relational databases in the Haskell
> > ecosystem.
> I'm very sorry, but I had a strong gut reaction to Manuels sentiment.
> Really?! What's so great about it? Isn't this rather a sign that
> something is askew? For such an important, ubiquitous yet mundane task
> as accessing database there shouldn't be so many ad hoc half-baked
> (sorry - with some limitations) solutions. That's unfair, I know.

Hello Riivo,

It's not clear to me from your message whether you've looked at Opaleye, a
relation query embedded domain specific language for Haskell


I wrote it, so all due caveats about my opinion apply, but I do not consider
Opaleye either ad hoc or half-baked.  Opaleye has a solid theoretical
foundation and thorough attention has been given to its semantics.

> I look at those examples and think, this is not the Haskell I'd like
> to write and despite type safety and composability, which are great
> features, it's not even the query language I'd like to write. Ie it's
> not better than SQL, yet.

If you feel this way about writing code using Opaleye perhaps you could be
more specific so I can get a clearer understanding of the issues involved.

> If Haskell hasn't got tuples as in relations (named, not ordered), type
> system such that tuple types' arity is not fixed (if that's the correct
> way to put it) and types for sets of such tuples aka relation type, then
> how can Haskell support databases and relational algebra NATURALLY?  On
> the other hand, if Haskell had those, it would be quite a relational
> language, right?  And a GREAT one, no?

I should mention at this point that I do not consider "relational algebra"
to be a paragon to which to aspire.  There is a lot of value in that body of
work, but in the light of developments in programming language semantics
over the last forty years relational algebra really appears to need an
overhaul.  (Technical note: One thing I noticed when writing Opaleye is that
restriction, projection and inner join are different sorts of operation than
aggregation and outer join, the former being what are called "algebraic
operations", the latter not.  I think the only way this observation can be
made is if you encode relational algebra in a typed setting.)

Opaleye is an implementation of relational algebra to about the same extent
that Haskell is an implementation of the untyped lambda calculus, and I'm
very happy with that difference between them.


More information about the Haskell-Cafe mailing list