language-haskell: ASTs, parser and pretty-printer for Haskell 2010 with most language extensions

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

A library and executable providing the parser, pretty-printer, and some AST transformations for the Haskell 2010 language and its syntactic extensions. The extension syntax is defined in form of independent grammar overlays, making it easy to set up new syntactic experiments.


[Skip to Readme]

Properties

Versions 0.1
Change log CHANGELOG.md
Dependencies base (>=4.14 && <5), bytestring (<0.13), containers (>=0.5.8 && <1), deep-transformations (>=0.3 && <0.4), directory (<2), either (>=5.0 && <5.1), filepath (<1.5), foldable1-classes-compat (<0.2), ghc-prim (<0.14), grammatical-parsers (>=0.6 && <0.8), input-parsers (>=0.2.2 && <0.4), language-haskell, memoize (>=1.1 && <1.2), monoid-subclasses (>=1.2.4 && <1.3), optparse-applicative (>=0.12 && <0.19), parsers (>=0.12.7 && <0.13), pretty (>=1.1 && <1.2), rank2classes (>=1.3 && <1.6), reducers (<4), repr-tree-syb (<0.2), template-haskell (>=2.11 && <2.24), text (<3), th-abstraction (>=0.4 && <0.8), transformers (>=0.5 && <0.7), witherable (>=0.4 && <0.6) [details]
License BSD-3-Clause
Author Mario Blažević
Maintainer blamario@protonmail.com
Category Language
Bug tracker https://github.com/blamario/language-Haskell/issues
Source repo head: git clone https://github.com/blamario/language-Haskell/
Uploaded by MarioBlazevic at 2025-05-31T23:32:38Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for language-haskell-0.1

[back to package description]

Mission statement

Much like the many other language-X Haskell libraries on Hackage and elsewhere, language-haskell provides the basic implementation of the Haskell programming langugage. Quite commonly for this crowd, this currently includes a parser and pretty printer and not much else.

Which Haskell you might ask?

The answer is all of them, aspirationally at least. The library covers the Haskell 2010 standard thoroughly, but it also supports a large number of GHC extensions. One goal of the library is to cover all known language extensions, while keeping any of them from compromising either the standard language base or the other extensions.

Design

To make this goal possible, the library relies on the finally-tagless encoding of the AST. It also keeps the language grammar modular: every extension that affects the language grammar defines an optional grammar overlay. The grammar used for parsing a particular Haskell module is composed for the purpose, based on the list of extensions it declares. The grammatical-parsers library provides all the tools used for this.

Every parsed AST node is contained by a wrapper node. Immediately after parsing, the wrapper carries the information about the node's position and the tokens consumed to parse it. This information is sufficient to xactly reproduce the original source code. In the next stage, the identifiers are bound to their definitions and the wrappers get enriched to carry the resolved environment. The discovered bindings are subsequently used to verify and correct the AST of sequences of infix and prefix operators.

After the AST goes through some transformations, it can be converted to Template Haskell expressions and finally pretty-printed.