diff --git a/haskell-indentation.el b/haskell-indentation.el index b07167159..44ea1c3df 100644 --- a/haskell-indentation.el +++ b/haskell-indentation.el @@ -795,15 +795,15 @@ parser. If parsing ends here, set indentation to left-indent." (defun haskell-indentation-declaration () "Parse function or type declaration." (haskell-indentation-separated #'haskell-indentation-expression "," nil) - (cond ((string= current-token "|") - (haskell-indentation-with-starter - (apply-partially #'haskell-indentation-separated - #'haskell-indentation-guard "|" nil) - nil)) - ((eq current-token 'end-tokens) - (when (member following-token '("|" "=" "::" ",")) - (haskell-indentation-add-indentation current-indent) - (throw 'parse-end nil))))) + (when (string= current-token "|") + (haskell-indentation-with-starter + (apply-partially #'haskell-indentation-separated + #'haskell-indentation-guard "|" nil) + nil)) + (when (eq current-token 'end-tokens) + (when (member following-token '("|" "=" "::" ",")) + (haskell-indentation-add-indentation current-indent) + (throw 'parse-end nil)))) (defun haskell-indentation-layout (parser) "Parse layout list, where each layout item is parsed by parser." diff --git a/tests/haskell-indentation-tests.el b/tests/haskell-indentation-tests.el index fb4255fe5..474d45e2d 100644 --- a/tests/haskell-indentation-tests.el +++ b/tests/haskell-indentation-tests.el @@ -882,6 +882,15 @@ fun = if | guard1 -> expr1 (2 9) (3 0 11)) +(hindent-test "54 equal after guards on separate line" " +foo x + | True + = X" + (1 0) + (2 2) + (3 2)) + + (ert-deftest haskell-indentation-ret-indents () (with-temp-switch-to-buffer (haskell-mode)