Skip to content
This repository has been archived by the owner on Jan 21, 2023. It is now read-only.
momomimachli edited this page Aug 19, 2016 · 8 revisions

Hedsql is an EDSL (Embedded Domain-Specific Language) written in Haskell for SQL. It allows to write SQL queries in Haskell such as:

query =
       select "col1"
    |> from "table1"
    |> end

which can then be translated to SQL:

SELECT "col1" FROM "table1"

The advantages of using such library rather than raw SQL can be:

  • less mistakes as the type system will ensure that your query is grammatically correct and can also statically check if the types of the elements matches;
  • easier composition: you can add or change parts of existing queries;
  • more portability: Hedsql takes care to convert your query to the correct format for a specific vendor;
  • more readable output: queries can be pretty printed.

The key aspects of Hesql compared to other parser libraries are the following ones:

  • it aims to run for 3 different databases (MariaDB, PostgreSQL and SqLite);
  • it offers a various amount of type correctness: you can use it in a very light way (no checks on the types) or in a much stricter way by providing their types to all elements (columns and values), or you can mix both;
  • its goal is to cover most of SQL language.
Clone this wiki locally