summaryrefslogtreecommitdiffhomepage
path: root/README.markdown
diff options
context:
space:
mode:
Diffstat (limited to 'README.markdown')
-rw-r--r--README.markdown101
1 files changed, 73 insertions, 28 deletions
diff --git a/README.markdown b/README.markdown
index 8f56ea6..4402a56 100644
--- a/README.markdown
+++ b/README.markdown
@@ -1,8 +1,8 @@
-stylish-haskell
-===============
+## stylish-haskell
-Introduction
-------------
+<img src="./assets/Logo/SVG/RoundedLogo.svg" width="100px">
+
+## 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,
@@ -10,8 +10,7 @@ manually cleaning up import statements etc. gets tedious very quickly.
This tool tries to help where necessary without getting in the way.
-Features
---------
+## Features
- Aligns and sorts `import` statements
- Groups and wraps `{-# LANGUAGE #-}` pragmas, can remove (some) redundant
@@ -22,13 +21,13 @@ Features
- Replaces tabs by four spaces (turned off by default)
- Replaces some ASCII sequences by their Unicode equivalents (turned off by
default)
+- Format data constructors and fields in records.
Feature requests are welcome! Use the [issue tracker] for that.
[issue tracker]: https://github.com/jaspervdj/stylish-haskell/issues
-Example
--------
+## Example
Turns:
@@ -46,10 +45,7 @@ import System.Directory (doesFileExist)
import qualified Data.Map as M
import Data.Map ((!), keys, Map)
-data Point = Point
- { pointX, pointY :: Double
- , pointName :: String
- } deriving (Show)
+data Point = Point { pointX, pointY :: Double , pointName :: String} deriving (Show)
```
into:
@@ -72,8 +68,8 @@ data Point = Point
, pointName :: String
} deriving (Show)
```
-Configuration
--------------
+
+## Configuration
The tool is customizable to some extent. It tries to find a config file in the
following order:
@@ -95,8 +91,62 @@ Use `stylish-haskell --defaults > .stylish-haskell.yaml` to dump a
well-documented default configuration to a file, this way you can get started
quickly.
-VIM integration
----------------
+## Record formatting
+
+Basically, stylish-haskell supports 4 different styles of records, controlled by `records`
+in the config file.
+
+Here's an example of all four styles:
+
+```haskell
+-- equals: "indent 2", "first_field": "indent 2"
+data Foo a
+ = Foo
+ { a :: Int
+ , a2 :: String
+ -- ^ some haddock
+ }
+ | Bar
+ { b :: a
+ }
+ deriving (Eq, Show)
+ deriving (ToJSON) via Bar Foo
+
+-- equals: "same_line", "first_field": "indent 2"
+data Foo a = Foo
+ { a :: Int
+ , a2 :: String
+ -- ^ some haddock
+ }
+ | Bar
+ { b :: a
+ }
+ deriving (Eq, Show)
+ deriving (ToJSON) via Bar Foo
+
+-- equals: "same_line", "first_field": "same_line"
+data Foo a = Foo { a :: Int
+ , a2 :: String
+ -- ^ some haddock
+ }
+ | Bar { b :: a
+ }
+ deriving (Eq, Show)
+ deriving (ToJSON) via Bar Foo
+
+-- equals: "indent 2", first_field: "same_line"
+data Foo a
+ = Foo { a :: Int
+ , a2 :: String
+ -- ^ some haddock
+ }
+ | Bar { b :: a
+ }
+ deriving (Eq, Show)
+ deriving (ToJSON) via Bar Foo
+```
+
+## VIM integration
Since it works as a filter it is pretty easy to integrate this with VIM.
@@ -124,14 +174,13 @@ autocmd FileType haskell let b:autoformat_autoindent=0
There are also plugins that run stylish-haskell automatically when you save a
Haskell file:
-* [vim-stylish-haskell]
-* [vim-stylishask]
+- [vim-stylish-haskell]
+- [vim-stylishask]
[vim-stylish-haskell]: https://github.com/nbouscal/vim-stylish-haskell
[vim-stylishask]: https://github.com/alx741/vim-stylishask
-Emacs integration
------------------
+## Emacs integration
[haskell-mode] for Emacs supports `stylish-haskell`. For configuration,
see [the “Using external formatters” section][haskell-mode/format] of the
@@ -140,8 +189,7 @@ haskell-mode manual.
[haskell-mode]: https://github.com/haskell/haskell-mode
[haskell-mode/format]: http://haskell.github.io/haskell-mode/manual/latest/Autoformating.html
-Atom integration
-----------------
+## Atom integration
[ide-haskell] for Atom supports `stylish-haskell`.
@@ -150,15 +198,13 @@ Atom integration
[ide-haskell]: https://atom.io/packages/ide-haskell
[atom-beautify]: Https://atom.io/packages/atom-beautify
-Visual Studio Code integration
-------------------------------
+## Visual Studio Code integration
[stylish-haskell-vscode] for VSCode supports `stylish-haskell`.
[stylish-haskell-vscode]: https://github.com/vigoo/stylish-haskell-vscode
-Using with Continuous Integration
----------------------------------
+## Using with Continuous Integration
You can quickly grab the latest binary and run `stylish-haskell` like so:
@@ -166,8 +212,7 @@ You can quickly grab the latest binary and run `stylish-haskell` like so:
Where the `.` can be replaced with the arguments you pass to `stylish-haskell`.
-Credits
--------
+## Credits
Written and maintained by Jasper Van der Jeugt.