hssqlppp: Sql parser and type checker

[ bsd3, database, language, library ] [ Propose Tags ]

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

See the project page https://launchpad.net/hssqlppp for more information and documentation links, there are also links to some example usage files there.

Quick module guide:

Ast - ast types;

Parser - converting strings to asts;

PrettyPrinter - converting asts to strings containing valid SQL;

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

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

Annotation - the annotation data types and utilities;

Catalog - read a catalog from a database to type check against, or to generate catalog information.

Also comes with command line access to some functions via a exe called HsSqlSystem, run this file with no arguments to get some help.

[Skip to Readme]
Versions [RSS] [faq] 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, 0.6.1, 0.6.2
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 BSD-3-Clause
Copyright Copyright 2010 Jake Wheat
Author Jake Wheat
Maintainer jakewheatmail@gmail.com
Category Database
Home page https://launchpad.net/hssqlppp
Bug tracker mailto:jakewheatmail@gmail.com
Uploaded by JakeWheat at 2010-01-27T00:42:20Z
Distributions NixOS:0.6.2
Executables HsSqlSystem
Downloads 12243 total (98 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
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.Catalog
        • Database.HsSqlPpp.Ast.SqlTypes
        • Database.HsSqlPpp.Ast.TypeChecker
      • Parsing
        • Database.HsSqlPpp.Parsing.Parser
      • PrettyPrinter
        • Database.HsSqlPpp.PrettyPrinter.PrettyPrinter


Maintainer's Corner

For package maintainers and hackage trustees


Readme for hssqlppp-0.2.0

[back to package description]
Summary: A parser, pretty printer, and type checker for PostgreSQL SQL
and PL/pgSQL. BSD licensed.

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, possibly: macros/ code generation/ custom
syntax, type safe access from Haskell, Lint-like checking,
documentation generation.

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

It's currently developed on GHC 6.12, but is tested on 6.10 before
each release so should work there too.

There isn't much in the way of documentation at the moment. See the
haddock docs locally or on hackage (link below), which also contain
links to a few example files. The source has a fair bit of comments,
which are currently OK in some places and poor in others.

The main dependencies of this project are: Parsec 3, HDBC,
HDBC-postgresql, and UUAGC is needed only for development). You 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



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.


Example files:

(remove the prefix
to get the local relative path)

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


The HsSqlSystem command source - HsSqlSystem.lhs.

AST transform code to extend plpgsql without any custom syntax, for
another project, early days:


Some type safe database access rough example code, all just half
finished demo ideas at the moment:

Simple idea to work as a preprocess to parse a haskell file and
convert some declarations into calls to a wrapper around HDBC, with
the correct type signatures, with the return type as a list of haskell


Similar to previous idea, but using template haskell to do the
substitution at compile time, not as a preprocessor:


example usage:


Use template haskell again, but type the return values as lists of
hlists instead of tuples, so that field names in haskell code are also
checked at compile time:


example usage: