opaleye: An SQL-generating DSL targeting PostgreSQL

[ bsd3, database, library ] [ Propose Tags ]

An SQL-generating DSL targeting PostgreSQL. Allows Postgres queries to be written within Haskell in a typesafe and composable fashion.

[Skip to Readme]
Versions [faq] 0.2, 0.3, 0.3.1,,,,,,,,,,,,,,,,, 0.6.7000.0, 0.6.7001.0, 0.6.7002.0, 0.6.7003.0, 0.6.7003.1, 0.6.7004.0 (info)
Change log CHANGELOG.md
Dependencies aeson (>=0.6 && <0.12), attoparsec (>=0.10.3 && <0.14), base (>=4.5 && <4.9), base16-bytestring (>= && <0.2), bytestring (==0.10.*), case-insensitive (==1.2.*), contravariant (>=1.2 && <1.5), postgresql-simple (>= && <0.6), pretty (>= && <1.2), product-profunctors (>=0.6.2 && <0.8), profunctors (>=4.0 && <5.3), semigroups (>=0.13 && <0.19), text (>=0.11 && <1.3), time (>=1.4 && <1.7), time-locale-compat (==0.1.*), transformers (>=0.3 && <0.6), uuid (==1.3.*), void (>=0.4 && <0.8) [details]
License BSD-3-Clause
Copyright Copyright (c) 2014-2015 Purely Agile Limited
Author Purely Agile
Maintainer Purely Agile
Revised Revision 7 made by tomjaguarpaw at Mon May 30 09:08:40 UTC 2016
Category Database
Home page https://github.com/tomjaguarpaw/haskell-opaleye
Bug tracker https://github.com/tomjaguarpaw/haskell-opaleye/issues
Source repo head: git clone https://github.com/tomjaguarpaw/haskell-opaleye.git
Uploaded by tomjaguarpaw at Thu Oct 8 09:41:33 UTC 2015
Distributions LTSHaskell:0.6.7004.0, NixOS:0.6.7004.0, Stackage:0.6.7004.0
Downloads 10974 total (236 in the last 30 days)
Rating 2.5 (votes: 4) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2015-10-08 [all 1 reports]




Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees

Readme for opaleye-

[back to package description]

Brief introduction to Opaleye Hackage version Build Status

Opaleye is a Haskell library that provides an SQL-generating embedded domain specific language for targeting Postgres. You need Opaleye if you want to use Haskell to write typesafe and composable code to query a Postgres database.

"Opaleye really is great. You've managed to bring what is so wonderful about relational databases and give it type safety and composition (i.e. what is wonderful about Haskell)" – Daniel Patterson, Position Development

Opaleye allows you to define your database tables and write queries against them in Haskell code, and aims to be typesafe in the sense that if your code compiles then the generated SQL query will not fail at runtime. A wide range of SQL functionality is supported including inner and outer joins, restriction, aggregation, distinct, sorting and limiting, unions and differences. Facilities to insert to, update and delete from tables are also provided. Code written using Opaleye is composable at a very fine level of granularity, promoting code reuse and high levels of abstraction.

Getting Opaleye


Please get started with Opaleye by referring to these two tutorials


Contact the author

The main author of Opaleye is Tom Ellis. He can be contacted via email.

File bugs

Please file bugs on the Opaleye GitHub issue tracking page.

Mailing list

Please join the opaleye-users mailing list.

Internal modules

Opaleye exports a number of modules named Opaleye.Internal..... They are provided in case of urgent need for access to the internals, but they are not intended to be used by API consumers and if you find yourself repeatedly accessing them this is a sign that either you or Opaleye are doing something wrong. In such a case please file a bug.

The interface of Internal modules does not follow the PVP and may break between minor releases, so be careful.

Commercial support

Commercial support for Opaleye is provided by Purely Agile.

Backup maintainers

In the event of the main developer becoming unreachable, please contact the following who are authorised to make bugfixes and dependency version bumps:

  • Adam Bergmark
  • Erik Hesselink
  • Oliver Charles


The Opaleye Project was founded by Tom Ellis, inspired by theoretical work on databases by David Spivak. Much of the implementation was based on ideas and code from the HaskellDB project by Daan Leijen, Conny Andersson, Martin Andersson, Mary Bergman, Victor Blomqvist, Bjorn Bringert, Anders Hockersten, Torbjorn Martin, Jeremy Shaw and Justin Bailey.

The following individuals and organisations have made helpful contributions:

  • Silk (Erik Hesselink, Adam Bergmark)
  • Karamaan (Christopher Lewis)
  • Fynder (Renzo Carbonara, Oliver Charles)
  • Daniel Patterson
  • Jakub Ryška
  • Travis Staton

Joseph Abrahamson, Alfredo Di Napoli and Mietek Bak performed useful reviews of early versions which helped improve the codebase.