brittany alternatives and similar packages
Based on the "Language" category.
Alternatively, view brittany alternatives based on common mentions on social networks and blogs.
elm-compiler10.0 0.0 brittany VS elm-compilerCompiler for Elm, a functional language for reliable webapps.
stylish-haskell9.9 6.4 brittany VS stylish-haskellHaskell code prettifier [Moved to: https://github.com/haskell/stylish-haskell]
liquidhaskell9.9 9.6 brittany VS liquidhaskellLiquid Types For Haskell
cryptol9.9 8.4 brittany VS cryptolCryptol: The Language of Cryptography
polysemy9.9 3.9 brittany VS polysemy:gemini: higher-order, no-boilerplate monads
elm-server9.8 0.0 brittany VS elm-serverServer for developing Elm projects
ivory9.8 0.0 brittany VS ivoryThe Ivory EDSL
elm-reactor9.8 0.0 brittany VS elm-reactorInteractive development tool for Elm programs
haskell-src-exts9.7 0.0 brittany VS haskell-src-extsManipulating Haskell source: abstract syntax, lexer, parser, and pretty-printer
elm-package9.7 0.0 brittany VS elm-packagePackage manager for Elm libraries
elm-get9.7 0.0 brittany VS elm-getTool for sharing and using Elm libraries
haskell-tools-ast-fromghcDeveloper tools for Haskell
frp-arduino9.6 0.0 brittany VS frp-arduinoArduino programming without the hassle of C.
haskell-tools-ast9.6 0.0 brittany VS haskell-tools-astDeveloper tools for Haskell
haskell-tools-ast-genDeveloper tools for Haskell
liquid-fixpoint9.5 7.2 brittany VS liquid-fixpointHorn Clause Constraint Solving for Liquid Types
nirum9.5 0.0 brittany VS nirumNirum: IDL compiler and RPC/distributed object framework for microservices
language-python9.5 0.0 brittany VS language-pythonA parser for Python 2.x and 3.x written in Haskell
axel9.5 5.3 brittany VS axelHaskell + Lisp
elm-export9.4 0.0 brittany VS elm-exportCreate Elm types and JSON decoders from Haskell source.
elsa9.4 0.0 brittany VS elsaElsa is a lambda calculus evaluator
language-java9.3 0.0 brittany VS language-javaJava parser and printer for haskell
tal9.3 0.0 brittany VS talAn implementation of Typed Assembly Language (Morrisett, Walker, Crary, Glew)
shentong9.3 0.0 brittany VS shentongA Haskell implementation of the Shen programming language.
hfmt9.2 0.0 brittany VS hfmtFormat Haskell programs. Inspired by the gofmt utility.
camfort9.2 0.0 brittany VS camfortLight-weight verification and transformation tools for Fortran
elm-bridge9.2 0.0 brittany VS elm-bridgeHaskell: Derive Elm types from Haskell types
hgrep9.1 0.8 brittany VS hgrepSearch Haskell source code from the command line
jvm-parser9.1 0.0 brittany VS jvm-parserA Haskell parser for JVM bytecode files
type-of-html9.1 0.0 brittany VS type-of-htmlHigh performance type safe html generation
peggy9.1 0.0 brittany VS peggyThe Parser Generator for Haskell
ghc-justdoit9.1 0.0 brittany VS ghc-justdoitA magic typeclass that just does it
language-c-quote9.0 0.0 brittany VS language-c-quoteC/CUDA/OpenCL/Objective-C quasiquoting library.
exference9.0 0.0 brittany VS exferenceHaskell tool to generate expressions from types
language-rust8.9 0.0 brittany VS language-rustParser and pretty-printer for the Rust language
language-ecmascript8.9 0.0 brittany VS language-ecmascriptHaskell library: ECMAScript parser, pretty-printer and additional tools
fortran-src8.8 0.0 brittany VS fortran-srcFortran parsing and static analysis infrastructure
formura8.8 0.0 L3 brittany VS formuraDescribe stencil formurae without even translating them
aterm-utils8.8 0.0 brittany VS aterm-utilsUtility functions for working with aterms as generated by Minitermite
why38.8 0.0 brittany VS why3Haskell support for the Why3 input format
imprevu8.8 0.0 brittany VS imprevuThe Nomyx game
homplexity8.8 0.0 brittany VS homplexityHaskell code complexity and quality measurement
nomyx-library8.8 0.0 brittany VS nomyx-libraryThe Nomyx game
haskell-names8.7 0.0 brittany VS haskell-namesHaskell suite library for name resolution
LibClang8.7 0.0 brittany VS LibClangHaskell FFI to libclang
ministg8.7 0.0 brittany VS ministgMinistg is an interpreter for a high-level, small-step, operational semantics for the STG machine.
mikrokosmos8.6 0.0 brittany VS mikrokosmos(λ) Educational lambda calculus interpreter
purescript-tsd-gen8.6 5.3 brittany VS purescript-tsd-genTypeScript Declaration File (.d.ts) generator for PureScript
Clean code begins in your IDE with SonarLint
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of brittany or a related project?
haskell source code formatter
(see more examples and comparisons)
This project's goals roughly are to:
- Always retain the semantics of the source being transformed;
- Be idempotent;
- Support the full GHC-haskell syntax including syntactic extensions
-XCPPwhich is too hard);
- Retain newlines and comments unmodified;
- Be clever about using the available horizontal space while not overflowing the column maximum unless it cannot be avoided;
- Be clever about aligning things horizontally (this can be turned off completely however);
- Have linear complexity in the size of the input.
In theory, the core algorithm inside brittany reaches these goals. It is rather clever about making use of horizontal space while still being linear in the size of the input (although the constant factor is not small). See these examples of clever layouting.
But brittany is not finished yet, and there are some open issues that yet require fixing:
- only the module header (imports/exports), type-signatures and function/value bindings are processed; other module elements (data-decls, classes, instances, etc.) are not transformed in any way; this extends to e.g. bindings inside class instance definitions - they won't be touched (yet).
- By using
ghc-exactprintas the parser, brittany supports full GHC including extensions, but some of the less common syntactic elements (even of 2010 haskell) are not handled.
- There are some known issues regarding handling of in-source comments. 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.)
Try without Installing
You can paste haskell code over here to test how it gets formatted by brittany. (Rg. privacy: the server does log the size of the input, but not the full input/output of requests.)
Other usage notes
- Supports GHC versions
- included in stackage with lts>=10.0 (or nightlies dating to >=2017-11-15)
- config (file) documentation is lacking.
- some config values can not be configured via commandline yet.
- uses/creates user config file in
~/.config/brittany/config.yaml; also reads (the first)
brittany.yamlfound in current or parent directories.
stack install brittany # --resolver lts-10.0
If you use an lts that includes brittany this should just work; otherwise you may want to clone the repo and try again (there are several stack.yamls included).
nix build nix-env -i ./result
Due to constant changes to the cabal UI, I have given up on making sure these instructions work before releases. Please do not expect these instructions to be up-to-date; they may produce incomprehensible error messages, they may be broken otherwise, they may work now but break with the next cabal release. Thanks for your understanding, and feel free to open issues for any problems you encounter. -- lennart
If you are using cabal-3.0, using
cabal install brittany --installdir=$HOME/.cabal/binmight work. Keep in mind that cabal merely puts a symlink to the "store" into the installdir, so you have to re-install if you ever clean your store. On cabal-2.4, try
cabal v2-install brittany. On cabal-2.2 or earlier you might be succesful using
cabal new-build exe:brittany; cp `find dist-newstyle/ -name brittany -type f | xargs -x ls -t | head -n1` $HOME/.cabal/bin/. Alternatively, you can also use the v1-approach with sandboxes as
cabal v1-sandbox init; cabal v1-install brittany --bindir=$HOME/.cabal/bin.
(TODO: These instructions are more confusing than helpful. I am inclined to just remove them.)
pacman -S haskell-brittany
Run a hoogle server
To host a local Hoogle server with all of Brittany's dependencies run:
echo brittany.cabal | $(nix-build '<nixpkgs>' --no-link -A entr)/bin/entr -r -- \ sh -c "nix-shell --run 'hoogle server --local'"
This will watch
brittany.cabal for changes and restart the server when new dependencies are added there.
In this gist I have described a haskell setup that includes a shortcut to run brittany formatting.
brittany to VSCode formatting API. Thanks to @MaxGabriel.
brittany plugin that directly uses the brittany library.
Relevant for any editors that properly support the language-server-protocol.
Neovim / Vim 8
The Neoformat plugin comes with support for brittany built in.
Atom Beautify supports brittany as a formatter for Haskell. Since the default formatter is set to hindent, you will need to change this setting to brittany, after installing the extension.
format-all support brittany as the default formatter for Haskell.
Default mode of operation: Transform a single module, from
stdout. Can pass one or multiple files as input, and there is a flag to override them in place instead of using
stdout(since 0.9.0.0). So:
brittany # stdin -> stdout brittany mysource.hs # ./mysource.hs -> stdout brittany --write-mode=inplace *.hs # apply formatting to all ./*.hs inplace
For stdin/stdout usage it makes sense to enable certain syntactic extensions by default, i.e. to add something like this to your
brittanyonce to create default):
conf_forward: options_ghc: - -XLambdaCase - -XMultiWayIf - -XGADTs - -XPatternGuards - -XViewPatterns - -XRecursiveDo - -XTupleSections - -XExplicitForAll - -XImplicitParams - -XQuasiQuotes - -XTemplateHaskell - -XBangPatterns
Feature Requests, Contribution, Documentation
For a long time this project has had a single maintainer, and as a consequence there have been some mildly large delays for reacting to feature requests and even PRs.
Sorry about that.
The good news is that this project is getting sponsored by PRODA LTD, and two previous contributors, Evan Borden and Taylor Fausak, have agreed on helping with organisational aspects. Thanks!
Still, this project has a long queue of very sensible feature requests, so it may take some time until new ones get our attention. But with the help of the co-maintainers, at least the reaction-times on PRs and the frequency of releases should improve significantly.
If you are interested in making your own contributions, there is a good amount of high-level documentation at
[the documentation index](doc/implementation/index.md)
Copyright (C) 2016-2019 Lennart Spitzner\ Copyright (C) 2019 PRODA LTD
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License, version 3, as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see http://www.gnu.org/licenses/.
*Note that all licence references and agreements mentioned in the brittany README section above are relevant to that project's source code only.