blob: 125822b4835a21280ef8a1e5e9e23cfc5a80f98d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
stylish-haskell
===============
[![Build Status](https://secure.travis-ci.org/jaspervdj/stylish-haskell.png?branch=master)](http://travis-ci.org/jaspervdj/stylish-haskell)
Introduction
------------
A simple Haskell code prettifier. The goal is not to format all of the code in
a file, since I find those kind of tools often "get in the way". However,
manually cleaning up import statements etc. gets tedious very quickly.
This tool tries to help where necessary without getting in the way.
You can install it using `cabal install stylish-haskell`.
Features
--------
- Aligns and sorts `import` statements
- Groups and wraps `{-# LANGUAGE #-}` pragmas
- Removes trailing whitespace
- Replaces tabs by four spaces (note that this is turned off by default)
Feature requests are welcome! Use the [issue tracker] for that.
[issue tracker]: https://github.com/jaspervdj/stylish-haskell/issues
Example
-------
Turns:
{-# LANGUAGE ViewPatterns, TemplateHaskell #-}
{-# LANGUAGE GeneralizedNewtypeDeriving,
ViewPatterns,
ScopedTypeVariables #-}
module Bad where
import Control.Applicative ((<$>))
import System.Directory (doesFileExist)
import qualified Data.Map as M
import Data.Map ((!), keys, Map)
into:
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE ViewPatterns #-}
module Bad where
import Control.Applicative ((<$>))
import System.Directory (doesFileExist)
import Data.Map (Map, keys, (!))
import qualified Data.Map as M
VIM integration
---------------
Since it works as a filter it is pretty easy to integrate this with VIM.
Just call
:%!stylish-haskell
or add a keybinding for it.
Emacs integration
-----------------
[haskell-mode] for Emacs supports `stylish-haskell`. For configuration, see
[Emacs/Formatting] on the HaskellWiki.
[haskell-mode]: https://github.com/haskell/haskell-mode
[Emacs/Formatting]: http://www.haskell.org/haskellwiki/Emacs/Formatting
|