You could start by building a combinator library suitable for
combining together a query (in a type-safe way).
While this is only one instance of doing this (having a certain
flavour) , the included SQL library in Open Quark might be
interesting.
Open Quark also has a SqlParser library that parses a particular SQL
query into an instance of a SQL query in terms of the SQL model. Of
course, you can also get a particular model to write itself out as a
SQL query (SELECT) syntax via a particular SQLBuilder.
Monads are often used to create domain specific embedded 'languages',
providing a nice encapsulation and interface to the backplane language
(e.g. the rest of CAL).