Some brief notes on developing with this code. UUAGC is used in the type checking, there are some links at the top of AstInternal.ag for more information. The code uses a few GHC extensions, I don't know if they are conservative extensions or not, see the cabal file and grep to find out the current list. Two of the files are generated: DefaultTemplate1Environment.hs -> generated using ./HsSqlSystem.lhs readenv template1 > something && cp something ... You shouldn't need to regenerate this file unless you change the Environment data type. AstInternal.hs -> this is generated from AstInternal.ag and Typechecking.ag using uuagc, see AstInternal.ag for the exact arguments to use. If you are editing either of these generated files directly you're probably doing something wrong. See the file 'usage' which documents a bunch of utility functions you can run from the command line, you can look and HsSqlSystem.lhs source for some example usage. There are rudimentary test for a lot of the functionality, see ParserTests.lhs and AstCheckTests.lhs (for type checking). These contain some small examples of how the code can be used. The HsSqlSystem.lhs file contains a few more examples. Source file overview: HsSqlSystem.lhs Main executable to provide command line access to library functions, mainly utilities to help with developing the source. Run './HsSqlSystem.lhs help' to list the commands. You can run the automated tests using './HsSqlSystem.lhs test'. All the other source code is under Database/HsSqlSystem/ Database/HsSqlPpp/Utils.lhs contains some small utility functions. The main folders under Database/HsSqlPpp are: Ast: public modules which forward parts of the internal ast and typechecking code AstInternals: private modules for ast, annotations, typechecking, etc. also contains all the .ag files. Commands: ErrorT wrappers for many library functions, used heavily in HsSqlSystem.lhs Dbms: Some rudimentary and half baked code to access databases. Extensions: expermental code for a syntax extension system for plpgsql HsText: code to help producing documentation: will process a text file, extract commands, run them, and interpolate the output into the text. Parsing: the parsing code PrettyPrinter: pretty printing code Tests: hunit tests Main code files: The main parsing code is in Database/HsSqlPpp/Parsing/Lexer.lhs and Database/HsSqlPpp/Parsing/Parser.lhs The main pretty printing code is in Database/HsSqlPpp/PrettyPrinter/PrettyPrinter.lhs and there is also some code to insert types, etc. into the original source in Database/HsSqlPpp/PrettyPrinter/AnnotateSource.lhs The main ast and typechecking code is in the following files: attribute grammar files: Database/HsSqlPpp/AstInternals/AstInternal.ag contains the ast nodes Database/HsSqlPpp/AstInternals/Typechecking/ contains the ATTR and SEM code for type checking These are supplemented by a bunch of helper modules: Database/HsSqlPpp/AstInternals/TypeConversion.lhs - contains the code which handles the implicit type cast resolution (these are postgresql algorithms used to lookup function calls, work out the types of result sets and check assignments). Database/HsSqlPpp/AstInternals/TypeCheckingH.lhs - contains some code which has been moved out of TypeChecking.ag for ease of development Database/HsSqlPpp/AstInternals/AstAnnotation.lhs - contains the data types and a few helper functions for the annotation data types. Database/HsSqlPpp/AstInternals/TypeType.lhs - contains the data types and a few helper functions for postgresql types, and also type errors. Database/HsSqlPpp/AstInternals/AstUtils.lhs - contains some error handling utils Database/HsSqlPpp/AstInternals/AnnotationUtils.lhs - contains some additional annotation functions which depend on the ast nodes the code to track environment changes during type checking (e.g. catalog changes, variables/bindings) is in the following two files: Database/HsSqlPpp/AstInternals/EnvironmentInternal.lhs - the main code to create, update and use environments. Database/HsSqlPpp/AstInternals/EnvironmentReader.lhs - code to read a catalog from a database and produce an environment value. Database/HsSqlPpp/AstInternals/DefaultTemplate1Environment.lhs - this is a copy of the default template1 database environment The code under Database/HsSqlPpp/AstInternals/ is hidden behind the public modules in Database/HsSqlPpp/Ast/: Database/HsSqlPpp/Ast/Annotator.lhs Database/HsSqlPpp/Ast/Ast.lhs Database/HsSqlPpp/Ast/Environment.lhs Database/HsSqlPpp/Ast/Annotation.lhs These pretty much just forward exports, and add a bit of haddock organisation. The hunit tests are in: Database/HsSqlPpp/Tests/AstCheckTests.lhs Database/HsSqlPpp/Tests/ParserTests.lhs and also this file which isn't really used yet: Database/HsSqlPpp/Tests/DatabaseLoaderTests.lhs There are a few utilities to access databases in Database/HsSqlPpp/Dbms/, this code is very sketchy. These files all have (hopefully) useful comments, although many of these haven't been kept up to date. The error handling in the type checking code is in flux so quite a lot of the code there is a bit of a mess unfortunately (I'm still not sure what the best way to do this is.). Also, some of the annotation functions use SYB which I'm a bit crap with so that code is also a bit of a mess. The test coverage isn't really great, but it's not bad (this will be fixed at some point). The bits which I hope aren't too bad are the ast node data types, the parser code, and the catalog code.