Skip to content

Commit 6c09f0b

Browse files
committed
Merge pull request #1106 from gracjan/pr-equals-after-guards
Honor equals on separate line after guards
2 parents 76d481a + 877f98c commit 6c09f0b

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

haskell-indentation.el

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -799,15 +799,15 @@ parser. If parsing ends here, set indentation to left-indent."
799799
(defun haskell-indentation-declaration ()
800800
"Parse function or type declaration."
801801
(haskell-indentation-separated #'haskell-indentation-expression "," nil)
802-
(cond ((string= current-token "|")
803-
(haskell-indentation-with-starter
804-
(apply-partially #'haskell-indentation-separated
805-
#'haskell-indentation-guard "|" nil)
806-
nil))
807-
((eq current-token 'end-tokens)
808-
(when (member following-token '("|" "=" "::" ","))
809-
(haskell-indentation-add-indentation current-indent)
810-
(throw 'parse-end nil)))))
802+
(when (string= current-token "|")
803+
(haskell-indentation-with-starter
804+
(apply-partially #'haskell-indentation-separated
805+
#'haskell-indentation-guard "|" nil)
806+
nil))
807+
(when (eq current-token 'end-tokens)
808+
(when (member following-token '("|" "=" "::" ","))
809+
(haskell-indentation-add-indentation current-indent)
810+
(throw 'parse-end nil))))
811811

812812
(defun haskell-indentation-layout (parser)
813813
"Parse layout list, where each layout item is parsed by parser."

tests/haskell-indentation-tests.el

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,15 @@ fun = if | guard1 -> expr1
888888
(2 9)
889889
(3 0 11))
890890

891+
(hindent-test "54 equal after guards on separate line" "
892+
foo x
893+
| True
894+
= X"
895+
(1 0)
896+
(2 2)
897+
(3 2))
898+
899+
891900
(ert-deftest haskell-indentation-ret-indents ()
892901
(with-temp-switch-to-buffer
893902
(haskell-mode)

0 commit comments

Comments
 (0)