Merge da48b5181f
into 8c5e0ef3b6
commit
5c5121ac9d
26
README.md
26
README.md
|
@ -1,4 +1,4 @@
|
|||
# brittany [](https://hackage.haskell.org/package/brittany) [](https://www.stackage.org/package/brittany) [](http://travis-ci.org/lspitzner/brittany)
|
||||
# brittany [](https://hackage.haskell.org/package/brittany) [](https://www.stackage.org/package/brittany) [](http://travis-ci.org/lspitzner/brittany)
|
||||
haskell source code formatter
|
||||
|
||||

|
||||
|
@ -31,7 +31,7 @@ require fixing:
|
|||
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-exactprint` as the parser, brittany supports full GHC
|
||||
- By using `ghc-exactprint` as 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.**
|
||||
|
@ -111,19 +111,37 @@ log the size of the input, but _not_ the full input/output of requests.)
|
|||
brittany built in.
|
||||
#### Atom
|
||||
[Atom Beautify](https://atom.io/packages/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.
|
||||
#### Emacs
|
||||
The following is an easy way to use `brittany` in Emacs
|
||||
```
|
||||
(defun brittany-format-buffer-file ()
|
||||
"run brittany command on the current file and revert the buffer"
|
||||
(interactive)
|
||||
(save-buffer)
|
||||
(shell-command
|
||||
(format "brittany %s --write-mode=inplace"
|
||||
(shell-quote-argument (buffer-file-name)))
|
||||
nil
|
||||
shell-command-default-error-buffer)
|
||||
(revert-buffer t t t))
|
||||
|
||||
(add-hook 'haskell-mode-hook
|
||||
(lambda ()
|
||||
(local-set-key (kbd "C-c C-f") 'brittany-format-buffer-file)))
|
||||
```
|
||||
|
||||
# Usage
|
||||
|
||||
- Default mode of operation: Transform a single module, from `stdin` to `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:
|
||||
|
||||
|
||||
~~~~ .sh
|
||||
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
|
||||
`~/.config/brittany/config.yaml` (execute `brittany` once to create default):
|
||||
|
|
Loading…
Reference in New Issue