diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..0f676483f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# http://editorconfig.org +root = true + +[Makefile] +indent_style = tabs +indent_size = 8 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{hs,md}] +indent_style = space +indent_size = 4 +tab_width = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +max_line_length = 80 diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 769b1063a..b49984d69 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -2,6 +2,8 @@ Before submitting your PR, check that you've: - [ ] Documented new APIs with [Haddock markup](https://www.haskell.org/haddock/doc/html/index.html) - [ ] Added [`@since` declarations](http://haskell-haddock.readthedocs.io/en/latest/markup.html#since) to the Haddock +- [ ] Ran `stylish-haskell` on any changed files. +- [ ] Adhered to the code style (see the `.editorconfig` file for details) After submitting your PR: diff --git a/.stylish-haskell.yaml b/.stylish-haskell.yaml new file mode 100644 index 000000000..6c825a0b1 --- /dev/null +++ b/.stylish-haskell.yaml @@ -0,0 +1,39 @@ +steps: + - imports: + align: none + list_align: with_module_name + pad_module_names: false + long_list_align: new_line_multiline + empty_list_align: inherit + list_padding: 7 # length "import " + separate_lists: false + space_surround: false + - language_pragmas: + style: vertical + align: false + remove_redundant: true + - simple_align: + cases: false + top_level_patterns: false + records: false + - trailing_whitespace: {} +indent: 4 +columns: 80 +newline: native +language_extensions: + - BlockArguments + - DataKinds + - DeriveGeneric + - DerivingStrategies + - DerivingVia + - ExplicitForAll + - FlexibleContexts + - MultiParamTypeClasses + - NamedFieldPuns + - OverloadedStrings + - QuantifiedConstraints + - RecordWildCards + - ScopedTypeVariables + - TemplateHaskell + - TypeApplications + - ViewPatterns diff --git a/README.md b/README.md index 313dae3d8..f69a497c9 100644 --- a/README.md +++ b/README.md @@ -34,3 +34,8 @@ Clone the repo and run `stack build` to build all targets. Persistent supports many backends. If you have only some of these installed the [development doc](development.md) shows how to build against a subset of targets. + +## Development + +For more information on how to hack ont he `persistent` set of libraries, see +the [`development.md`](development.md) file. diff --git a/development.md b/development.md index cdcf1090f..6e7a43471 100644 --- a/development.md +++ b/development.md @@ -1,3 +1,28 @@ +# Style Guide + +## `stylish-haskell` + +This repository uses +[`stylish-haskell`](https://hackage.haskell.org/package/stylish-haskell) as an +autoformatter. `stylish-haskell` is inherently limited, so it won't handle +everything, but it will format import lists, extension lists, etc. + +## `editorconfig` + +This repository has an `.editorconfig` file for use with the +[`EditorConfig`](https://editorconfig.org/) tool. It's recommended to install +the tool so that the editor style is picked up automatically. + +## General Style Guide + +Prefer 4 space indentation. If the line gets too long, refactor the code - pull +out named terms into `let` or `where` bindings (or top-level functions). + +Prefer `case` expressions over combinators. Prefer `do` notation over combinators. +It's easier, simpler, and faster to read and modify these forms than more +concise versions, even where the more concise version is faster to write at +first. + # Building with Backends With all required backends installed, `stack build` can build all packages @@ -17,7 +42,7 @@ will fail as will builds for packages for those backends alone: Process exited with code: ExitFailure 1 Configuring mysql-0.1.4... setup: The program 'mysql_config' is required but it could not be found - + > stack build persistent-postgresql ... Process exited with code: ExitFailure 1