An haskell port of the java version of gom http://github.com/polux/hgom

Latest on Hackage:0.6

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

GPL licensed by Paul Brauner and Emilie Balland
Maintained by Paul Brauner


An haskell clone of the original java Gom code generator.


To compile hgom, install cabal-install and type the following.

cabal configure
cabal build

The hgom binary is generated in dist/build/hgom.


cabal install

Generate developer documentation

By default, cabal generates no documentation since only the executable is exported. Developers still can generate the modules' documentation as follows.

cabal haddock --executables \
--html-location='http://hackage.haskell.org/packages/archive/$pkg/latest/doc/html' \

Only exported symbols are documented. Add --internal for unexported symbols documentation.

The documentation index is then dist/doc/html/hgom/hgom/index.html.

Running hgom

Run hgom --help to get some basic help. You can test the behaviour of hgom by running it as follows. Some examples are valid files, other ones demonstrate hgom error messages.

hgom examples/simple.gom
hgom examples/big.gom
hgom examples/many_errors.gom


The test suite is compiled only if the test flag is set. For instance, run

cabal configure -ftest
cabal build
./dist/build/hgom/hgom --test "-a n"


cabal install -ftest
hgom --test "-a n"

where n is the number of generated random inputs for each test case.

For other arguments to the --test option, try hgom --test "--help".

Code Coverage

Code coverage can be tested as follows.

cabal build --ghc-options "-fhpc -fforce-recomp"
cd test/coverage

The documentation is generated in test/coverage/html.


There is some benchmark in test/bench that generates bigger and bigger gom files and runs hgom and gom on them, measuring the gom/hgom ratio concerning the number of generated lines (using sloccount) and the elapsed time.

cd test/bench

It takes some time. The generated files can be plotted using gnuplot for instance.

Differences with gom


  • faster !
  • a far less permissive checker
  • smaller code, compiles much faster
  • almost 100% code coverage,
  • unit tests using QuickCheck, both on compiler data structures and generated code
  • regression tests for parser and checker
  • more things optional: visitable, checker, ...
  • toHaskell, makeRandom, depth and size methods generation (optional)
  • smaller code for some generated methods (string escaping factorized for instance)
  • faster code for some generated methods (less function calls, more constants)
  • faster parser (from*) methods: don't use an intermediate ATerm representation
  • pretty-printed generated code, optional compact (no indentation) option


  • no hooks!
  • no ant task
  • imports only builtins
  • generates no comments


  • slightly different command-line arguments syntax


hgom Changelog

version 0.6

  • fixed critical bug (par instead of __par)
  • added Make_C and Is_C classes generation

version 0.5.3

  • first public release
Depends on 7 packages:
Used by 1 package:
comments powered byDisqus