hindent 5.3.1 → 5.3.2
raw patch · 6 files changed
+61/−32 lines, 6 filesnew-uploaderPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- HIndent.Types: readExtension :: Monad m => String -> m Extension
+ HIndent.Types: readExtension :: (Monad m, MonadFail m) => String -> m Extension
Files
- README.md +22/−4
- elisp/hindent.el +12/−15
- hindent.cabal +13/−9
- src/HIndent/Pretty.hs +7/−3
- src/HIndent/Types.hs +6/−0
- src/main/Test.hs +1/−1
README.md view
@@ -1,8 +1,8 @@-# hindent [](https://hackage.haskell.org/package/hindent) [](https://travis-ci.org/commercialhaskell/hindent)+# hindent [](https://hackage.haskell.org/package/hindent) /badge.svg) /badge.svg) Haskell pretty printer -[Examples](https://github.com/commercialhaskell/hindent/blob/master/TESTS.md)+[Examples](https://github.com/mihaimaruseac/hindent/blob/master/TESTS.md) ## Install @@ -43,14 +43,32 @@ indent-size: 2 line-length: 80 force-trailing-newline: true+line-breaks: [":>", ":<|>"]+extensions:+ - DataKinds+ - GADTs+ - TypeApplications ``` -By default, HIndent preserves the newline or lack of newline in your input. With `force-trailing-newline`, it will make sure there is always a trailing newline.+By default, hindent preserves the newline or lack of newline in your input. With `force-trailing-newline`, it will make sure there is always a trailing newline. +hindent can be forced to insert a newline before specific operators and tokens with `line-breaks`. This is especially useful when utilizing libraries like [`servant`](https://www.servant.dev/) which use long type aliases.++Using `extensions`, hindent can be made aware of valid syntactic compiler extensions that would normally be considered invalid syntax.++It is also possible to specify which extensions HIndent runs+with in your `.hindent.yaml`:++```yaml+extensions:+ - MagicHash+ - RecursiveDo+```+ ## Emacs In-[elisp/hindent.el](https://github.com/commercialhaskell/hindent/blob/master/elisp/hindent.el)+[elisp/hindent.el](https://github.com/mihaimaruseac/hindent/blob/master/elisp/hindent.el) there is `hindent-mode`, which provides keybindings to reindent parts of the buffer:
elisp/hindent.el view
@@ -169,7 +169,7 @@ (insert new-string)))))) ;;;###autoload-(define-obsolete-function-alias 'hindent/reformat-decl 'hindent-reformat-decl)+(define-obsolete-function-alias 'hindent/reformat-decl 'hindent-reformat-decl "hindent 5.2.2") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;@@ -213,22 +213,19 @@ (goto-char (point-max)) (when (looking-back "\n" (1- (point))) (delete-char -1)))+ (delete-trailing-whitespace) (buffer-string)))) (if (not (string= new-str orig-str))- (let ((line (line-number-at-pos))- (col (current-column)))- (delete-region beg- end)- (let ((new-start (point)))- (insert new-str)- (let ((new-end (point)))- (goto-char (point-min))- (forward-line (1- line))- (goto-char (+ (line-beginning-position) col))- (when (looking-back "^[ ]+" (line-beginning-position))- (back-to-indentation))- (delete-trailing-whitespace new-start new-end)))- (message "Formatted."))+ (progn+ (if (fboundp 'replace-region-contents)+ (replace-region-contents+ beg end (lambda () temp))+ (let ((line (line-number-at-pos))+ (col (current-column)))+ (delete-region beg+ end)+ (insert new-str)))+ (message "Formatted.")) (message "Already formatted."))))))))))) (defun hindent-decl-points ()
hindent.cabal view
@@ -1,20 +1,20 @@ name: hindent-version: 5.3.1+version: 5.3.2 synopsis: Extensible Haskell pretty printer description: Extensible Haskell pretty printer. Both a library and an executable. .- See the Github page for usage\/explanation: <https://github.com/commercialhaskell/hindent>+ See the Github page for usage\/explanation: <https://github.com/mihaimaruseac/hindent> license: BSD3 stability: Unstable license-file: LICENSE.md-author: Chris Done, Andrew Gibiansky, Tobias Pflug, Pierre Radermecker-maintainer: chrisdone@gmail.com-copyright: 2014 Chris Done, 2015 Andrew Gibiansky+author: Mihai Maruseac, Chris Done, Andrew Gibiansky, Tobias Pflug, Pierre Radermecker+maintainer: mihaimaruseac@gmail.com+copyright: 2014 Chris Done, 2015 Andrew Gibiansky, 2021 Mihai Maruseac category: Development build-type: Simple-cabal-version: >=1.8-homepage: https://github.com/commercialhaskell/hindent-bug-reports: https://github.com/commercialhaskell/hindent/issues+cabal-version: >=1.10+homepage: https://github.com/mihaimaruseac/hindent+bug-reports: https://github.com/mihaimaruseac/hindent/issues data-files: elisp/hindent.el extra-source-files: README.md@@ -24,11 +24,12 @@ source-repository head type: git- location: https://github.com/commercialhaskell/hindent+ location: https://github.com/mihaimaruseac/hindent library hs-source-dirs: src/ ghc-options: -Wall -O2+ default-language: Haskell2010 exposed-modules: HIndent HIndent.Types HIndent.Pretty@@ -52,6 +53,7 @@ executable hindent hs-source-dirs: src/main ghc-options: -Wall -O2+ default-language: Haskell2010 main-is: Main.hs other-modules: Path.Find build-depends: base >= 4 && < 5@@ -74,6 +76,7 @@ test-suite hindent-test type: exitcode-stdio-1.0 hs-source-dirs: src/main/+ default-language: Haskell2010 main-is: Test.hs other-modules: Markdone build-depends: base >= 4 && <5@@ -93,6 +96,7 @@ benchmark hindent-bench type: exitcode-stdio-1.0 hs-source-dirs: src/main+ default-language: Haskell2010 ghc-options: -Wall -O2 -rtsopts main-is: Benchmark.hs other-modules: Markdone
src/HIndent/Pretty.hs view
@@ -979,17 +979,20 @@ instance Pretty Asst where prettyInternal x = case x of- ClassA _ name types -> spaced (pretty name : map pretty types)- i@InfixA {} -> pretty' i IParam _ name ty -> do pretty name write " :: " pretty ty+ ParenA _ asst -> parens (pretty asst)+#if MIN_VERSION_haskell_src_exts(1,21,0)+ TypeA _ ty -> pretty ty+#else+ ClassA _ name types -> spaced (pretty name : map pretty types)+ i@InfixA {} -> pretty' i EqualP _ a b -> do pretty a write " ~ " pretty b- ParenA _ asst -> parens (pretty asst) AppA _ name tys -> spaced (pretty name : map pretty tys) WildCardA _ name ->@@ -998,6 +1001,7 @@ Just n -> do write "_" pretty n+#endif instance Pretty BangType where prettyInternal x =
src/HIndent/Types.hs view
@@ -1,3 +1,4 @@+{-# OPTIONS_GHC -cpp #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE GADTs #-}@@ -71,7 +72,12 @@ } -- | Parse an extension.++#if __GLASGOW_HASKELL__ >= 808+readExtension :: (Monad m, MonadFail m) => String -> m Extension+#else readExtension :: Monad m => String -> m Extension+#endif readExtension x = case classifyExtension x -- Foo of
src/main/Test.hs view
@@ -61,7 +61,7 @@ shouldBeReadable (reformat cfg code) (L.fromStrict codeExpect) go next' _ ->- fail+ error "'haskell given' block must be followed by a 'haskell expect' block" "haskell pending" -> do it (UTF8.toString desc) pending