The hssqlppp package

[Tags:bsd3, library, test]

Sql parser, pretty printer and type checker, targets PostgreSQL SQL and PL/pgSQL, uses Parsec and UUAGC.


see the module Ast for the ast types;

Parser for converting text to asts;

PrettyPrinter for converting asts to text;

AnnotateSource for pretty printing annotations inline with original source;

TypeChecker for type checking and annotating asts and working with annotated trees;

SqlTypes for the data types which represent SQL types, the data type for type errors, and some support functions;

Annotation for the annotation data types and utilities;

Environment to read a catalog from a database to type check against, or to generate catalog information;

DatabaseLoader for the beginnings of a routine to load SQL into a database (e.g. to generate an ast then load it into a database without loading it via psql). The loader just about does the job but error handling is a bit crap at the moment.

CommandComponents for the component functions used in the HsSqlSystem exe.

ChaosExtensions for the experimental plpgsql syntax extensions.

Comes with command line access to some functions via a exe called HsSqlSystem, run this file with no arguments to get some help. Has a HUnit test suite which you can run using the HsSqlSystem executable. for the time being you can look at the source of this command to see what it can do:

See the project page for more information and documentation links.

The test files for parsing and for type checking contain examples of what parses/ typechecks and what the asts and annotations look like:

[Skip to Readme]


Versions 0.0.4, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.0.9, 0.0.10, 0.1.0, 0.2.0, 0.3.0, 0.3.1, 0.4.0, 0.4.1, 0.4.2, 0.6.0
Dependencies base (==4.*), cmdargs, containers, directory, filepath, haskell-src-exts, haskell98, HDBC, HDBC-postgresql, HUnit, mtl, parsec (>=3), Pipe, pretty, pretty-show, process, regex-posix, syb, template-haskell, test-framework, test-framework-hunit, uniplate [details]
License BSD3
Copyright Copyright 2009 Jake Wheat
Author Jake Wheat
Category Database
Home page
Bug tracker
Uploaded Wed Jan 13 23:59:41 UTC 2010 by JakeWheat
Distributions NixOS:0.6.0
Downloads 3253 total (60 in the last 30 days)
0 []
Status Docs not available [build log]
All reported builds failed as of 2016-12-30 [all 6 reports]


  • Database
    • HsSqlPpp
      • Ast
        • Database.HsSqlPpp.Ast.Annotation
        • Database.HsSqlPpp.Ast.Ast
        • Database.HsSqlPpp.Ast.Environment
        • Database.HsSqlPpp.Ast.SqlTypes
        • Database.HsSqlPpp.Ast.TypeChecker
      • Commands
        • Database.HsSqlPpp.Commands.CommandComponents
      • Dbms
        • Database.HsSqlPpp.Dbms.DatabaseLoader
      • Extensions
        • Database.HsSqlPpp.Extensions.ChaosExtensions
      • Parsing
        • Database.HsSqlPpp.Parsing.Parser
      • PrettyPrinter
        • Database.HsSqlPpp.PrettyPrinter.AnnotateSource
        • Database.HsSqlPpp.PrettyPrinter.PrettyPrinter


Maintainer's Corner

For package maintainers and hackage trustees

Readme for hssqlppp

Readme for hssqlppp-0.1.0

Summary: A parser, pretty printer, and type checker for PostgreSQL SQL
and PL/pgSQL. BSD licensed.

** Some of the documentation here and in the other files is out of
   date, will be updated before the first alpha release. Please email
   me (address below) if you have any questions in the meantime **

The current aims of the project is to provide a parser and type
checker for a substantial portion of PostgreSQL SQL and PL/pgSQL, and
then hopefully to build on this to make tools and libraries to help
developing PL/pgSQL code.

Status: it successfully parses and accurately pretty prints the three
moderate sized SQL files from another project of mine, but there are
lots of missing bits. Coverage of SQL is sort of reasonable - it's
possible that your SQL files will parse ok, but it's also possible
that they won't parse at all. Please report any sql which doesn't

It also has the beginnings of a type checker, which currently can type
check a fair bit of the three files mentioned above. You can run the
type checker on your SQL in various ways from the command line. Please
report any sql which doesn't type check correctly. Coming soon: a
command to produce a report on how well this code can parse and type
check your sql.

It comes with a small test suite.

To install, use
cabal update
cabal install hssqlppp

I think it should work on all GHC 6.10.x and possibly also GHC 6.8.x,
YMMV. GHC 6.12.x untested so far.

There are more doc files in the docs/ folder, and you can view the
haddock docs on hackage (see below for link). Better documentation is
coming soon.

The main dependencies of this project are: Parsec 3, HUnit, HDBC,
UUAGC. You currently need PostgreSQL installed.



There isn't really a homepage or website yet, but you can view the
Launchpad page where the code is hosted, and the HackageDB page.


HackageDB page:
You can also browse the limited Haddock documentation online here.

You can get the latest development code from Launchpad using Bazaar:
bzr branch lp:~jakewheat/hssqlppp/trunk

To get a snapshot release, see the downloads on the Launchpad page, or
use cabal install.



Let me know if you're using/ interesting in using the library, if you
have any problems or suggestions, etc.. All contributions, comments
and criticism welcome:

You can also report problems on the bug tracker on Launchpad.


= Some provisional future plans:

* use this system to develop a Lint-type checker for PL/pgSQL;

* provide support to help developing SQL from an IDE (targeting Emacs

* support type checking simple SQL statements that you'd embed in
  Haskell code, including with ? placeholders, to support generating
  type safe wrappers - could integrate with MetaHDBC?;

* possibly a lightweight code generation/ simple macro support to help
  with developing more robust PL/pgSQL code.

* documentation generation