diff --git a/haskell-indentation.el b/haskell-indentation.el index e0d526166..facabb370 100644 --- a/haskell-indentation.el +++ b/haskell-indentation.el @@ -603,7 +603,7 @@ the current buffer." ;; tokens in type declarations (defconst haskell-indentation-type-list '(("::" . (lambda () (haskell-indentation-with-starter - (lambda () (haskell-indentation-separated #'haskell-indentation-type "->"))))) + (lambda () (haskell-indentation-separated #'haskell-indentation-type '("->" "=>")))))) ("(" . (lambda () (haskell-indentation-list #'haskell-indentation-type ")" ","))) ("[" . (lambda () (haskell-indentation-list #'haskell-indentation-type "]" ","))) ("{" . (lambda () (haskell-indentation-list #'haskell-indentation-type "}" ","))))) @@ -634,7 +634,7 @@ the current buffer." ("where" . (lambda () (haskell-indentation-with-starter #'haskell-indentation-declaration-layout nil t))) ("::" . (lambda () (haskell-indentation-with-starter - (lambda () (haskell-indentation-separated #'haskell-indentation-type "->"))))) + (lambda () (haskell-indentation-separated #'haskell-indentation-type '("->" "=>")))))) ("=" . (lambda () (haskell-indentation-statement-right #'haskell-indentation-expression))) ("<-" . (lambda () (haskell-indentation-statement-right #'haskell-indentation-expression))) ("(" . (lambda () (haskell-indentation-list #'haskell-indentation-expression ")" '(list "," "->")))) @@ -699,7 +699,7 @@ the current buffer." ((eq current-token 'end-tokens) (when (member following-token '(value operator no-following-token - "->" "(" "[" "{" "::")) + "(" "[" "{" "::")) (haskell-indentation-add-indentation current-indent)) (throw 'return nil)) (t (let ((parser (assoc current-token haskell-indentation-type-list))) @@ -1164,7 +1164,7 @@ the current buffer." (match-string-no-properties 1)) ((looking-at "[][(){}[,;]") (match-string-no-properties 0)) - ((looking-at "\\(\\\\\\|->\\|→\\|<-\\|←\\|::\\|∷\\|=\\||\\)\\([^-:!#$%&*+./<=>?@\\\\^|~]\\|$\\)") + ((looking-at "\\(\\\\\\|->\\|=>\\|→\\|<-\\|←\\|::\\|∷\\|=\\||\\)\\([^-:!#$%&*+./<=>?@\\\\^|~]\\|$\\)") (match-string-no-properties 1)) ((looking-at "\\(→\\|←\\|∷\\)\\([^-:!#$%&*+./<=>?@\\\\^|~]\\|$\\)") (let ((tok (match-string-no-properties 1))) diff --git a/tests/haskell-indentation-tests.el b/tests/haskell-indentation-tests.el index 45044a4fc..7ee3623aa 100644 --- a/tests/haskell-indentation-tests.el +++ b/tests/haskell-indentation-tests.el @@ -195,3 +195,32 @@ Example of lines: (haskell-indentation-check "fun = \x ->" " ^")) + +(ert-deftest haskell-indentation-check-17a () + "A type for a function" + (haskell-indentation-check + "fun :: Int" + " -> Int" + " ^")) + +(ert-deftest haskell-indentation-check-17b () + "A type for a function with context" + (haskell-indentation-check + "fun :: Monad m" + " => Int" + " ^")) + +(ert-deftest haskell-indentation-check-17c () + "A type for a function with complicated context" + (haskell-indentation-check + "fun :: (Monad m, MonadBaseControl IO m, MyMonad (A v) m)" + " => MyMonad (A v) m" + " ^")) + +(ert-deftest haskell-indentation-check-17d () + "A type for a function with param and a complicated context" + (haskell-indentation-check + "fun :: (Monad m, MonadBaseControl IO m, MyMonad (A v) m)" + " => MyMonad (A v) m" + " -> m (Maybe a)" + " ^"))