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

Kei Hibino ex8k.hibino at gmail.com
Fri Dec 19 03:39:01 UTC 2014



From: Manuel Gómez <targen at gmail.com>
Subject: Re: [Haskell-cafe] [ANN] relational-record - relational-algebraic query building DSL
Date: Sun, 14 Dec 2014 12:22:25 -0430

> On Sun, Dec 14, 2014 at 12:04 PM, Kei Hibino <ex8k.hibino at gmail.com> wrote:
>> I am happy to announce relational-record library and its project page.
>>
>> relational-record is domain specific language for type-safe SQL query building,
>> and database access API with compile time schema generators.
>
> Congratulations on the release!  It’s great to see more and more
> interesting abstractions for relational databases in the Haskell
> ecosystem.
>
> It looks like this project shares many goals with Tom Ellis’ excellent
> and recently released[1] Opaleye library.  How would you say your
> approach compares with Opaleye’s?
>
> [1]: <www.reddit.com/r/haskell/comments/2nxx7n/announcing_opaleye_sqlgenerating_embedded_domain/>
>

Relational Record and Opaleye resembles in approach of building
not aggregated SQL query.

Opaleye's method using arrow notation is very cool.
So I try thin wrapper using Kleisli arrow.

https://gist.github.com/khibino/57405584b168d98fd1e8

If not arrow version is like below,

> personAndJoin :: QuerySimple (Projection Flat (Person, Birthday))
> personAndJoin = do
>   p <- query person
>   b <- query birthday
>   wheres $ p ! Person.name' .=. b ! Birthday.name'
>   return $ p >< b

Arrow version is like this with this wrapper.

> personAndJoinA :: QuerySimple () (Projection Flat (Person, Birthday))
> personAndJoinA =  proc () -> do
>   p <- query -< person
>   b <- query -< birthday
>   wheres -< p ! Person.name' .=. b ! Birthday.name'
>   returnA -< p >< b


Aggregation approaches differ.
Relational Record accumulates aggregated context into monad stack,
and Opaleye does not.

Relational Record basically accumulates various query state into monad stack
like join product, group keys and ordering.


More information about the Haskell-Cafe mailing list