haskell source code formatter
 
 
Go to file
Lennart Spitzner 1ce40c861c Various minor layouting fixes 2016-08-03 22:13:41 +02:00
src/Language/Haskell Various minor layouting fixes 2016-08-03 22:13:41 +02:00
src-brittany Change/Amend program/version description 2016-07-30 15:43:06 +02:00
src-idemtests Squash previous history 2016-07-30 15:22:07 +02:00
src-unittests Squash previous history 2016-07-30 15:22:07 +02:00
srcinc Squash previous history 2016-07-30 15:22:07 +02:00
.gitignore Squash previous history 2016-07-30 15:22:07 +02:00
ChangeLog.md Squash previous history 2016-07-30 15:22:07 +02:00
README.md Update README.md 2016-07-30 23:22:14 +02:00
Setup.hs Squash previous history 2016-07-30 15:22:07 +02:00
Showcase.md Create Showcase.md 2016-07-30 23:43:04 +02:00
brittany.cabal Minor cleanup, Add -rtsopts to unittests 2016-08-02 13:54:56 +02:00

README.md

brittany

haskell source code formatter

This project's goals roughly are to:

  • Be idempotent (this also directly ensures that only valid haskell is produced);
  • Support the full ghc-haskell syntax including syntactic extensions;
  • Retain newlines and comments unmodified;
  • Be clever about using the available horizontal space while not overflowing it if it cannot be avoided;
  • Be clever about aligning things horizontally.
  • Have linear complexity in the size of the input.

At this point, these goals are completed to different degrees. It is not ensured that only syntactically valid haskell is produced (yet), and coverage of the project's testsuite is rather limited. By using ghc-exactprint as the parser, brittany supports full ghc syntax including extensions, but many of the more obscure cases are not handled yet. More importantly, only type-signatures and function/value bindings are processed; other module elements (data-decls, classes, instances, imports/exports etc.) are not transformed in any way; this extends to e.g. bindings inside class instance definitions - they won't be touched (yet).

The current algorithm is rather clever about horizontal space while still being linear in the size of the input (although the constant factor is not small).

Important notes

  • -XCPP is not officially supported (yet).
  • Some commandline flags mentioned in the help don't work yet (and won't even be parsed correctly.)
  • Creates a brittany.yaml config file in the current directory. I am aware that this behaviour is not optimal.
  • Currently some unhandled syntactical constructs don't raise errors; in such cases the output will contain ghc-exactprint'ed code and some debugging comment. This could easily make the output invalid haskell.
  • There are cases where comments are not copied to the output (this will be detected and the user will get an error); there are other cases where comments are moved slightly; there are also cases where comments result in wonky newline insertion (although this should be a purely aesthetic issue.)

Usage

  • Currently one mode of operation: Transform a single module. By default read from stdin and written to stdout, but commandline arguments allow to read/write from/to files.