diff options
author | Maxim Koltsov <kolmax94@gmail.com> | 2020-02-17 19:32:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-17 19:32:01 +0100 |
commit | b8a731eb948b98019b8663c6fc653d2c930df2b1 (patch) | |
tree | ac2b95867755910564075caac605636e9babcaf7 /README.markdown | |
parent | ab85690eb35dec46c8eb80a930337249f34b9f80 (diff) | |
download | stylish-haskell-b8a731eb948b98019b8663c6fc653d2c930df2b1.tar.gz |
Introduce nicer style for records (#266)
Diffstat (limited to 'README.markdown')
-rw-r--r-- | README.markdown | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/README.markdown b/README.markdown index 54451cc..e420417 100644 --- a/README.markdown +++ b/README.markdown @@ -33,6 +33,7 @@ You can also install it using your package manager: - 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. @@ -102,6 +103,61 @@ Use `stylish-haskell --defaults > .stylish-haskell.yaml` to dump a well-documented default configuration to a file, this way you can get started quickly. +## 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. |