Skip to content

Commit 69562d3

Browse files
committed
Temporarily revert Align -> and => with :: in type declaration
It gets in the way for indentation of instance declarations with contexts, like: instance (Monoid a) => Applicative (Either2 a) where pure = Right2
1 parent fa17e69 commit 69562d3

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

haskell-indentation.el

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ the current buffer."
606606
;; tokens in type declarations
607607
(defconst haskell-indentation-type-list
608608
'(("::" . (lambda () (haskell-indentation-with-starter
609-
(lambda () (haskell-indentation-separated #'haskell-indentation-type '("->" "=>"))))))
609+
(lambda () (haskell-indentation-separated #'haskell-indentation-type "->")))))
610610
("(" . (lambda () (haskell-indentation-list #'haskell-indentation-type ")" ",")))
611611
("[" . (lambda () (haskell-indentation-list #'haskell-indentation-type "]" ",")))
612612
("{" . (lambda () (haskell-indentation-list #'haskell-indentation-type "}" ",")))))
@@ -637,7 +637,7 @@ the current buffer."
637637
("where" . (lambda () (haskell-indentation-with-starter
638638
#'haskell-indentation-declaration-layout nil t)))
639639
("::" . (lambda () (haskell-indentation-with-starter
640-
(lambda () (haskell-indentation-separated #'haskell-indentation-type '("->" "=>"))))))
640+
(lambda () (haskell-indentation-separated #'haskell-indentation-type "->")))))
641641
("=" . (lambda () (haskell-indentation-statement-right #'haskell-indentation-expression)))
642642
("<-" . (lambda () (haskell-indentation-statement-right #'haskell-indentation-expression)))
643643
("(" . (lambda () (haskell-indentation-list #'haskell-indentation-expression ")" '(list "," "->"))))
@@ -702,7 +702,7 @@ the current buffer."
702702
((eq current-token 'end-tokens)
703703
(when (member following-token
704704
'(value operator no-following-token
705-
"(" "[" "{" "::"))
705+
"->" "(" "[" "{" "::"))
706706
(haskell-indentation-add-indentation current-indent))
707707
(throw 'return nil))
708708
(t (let ((parser (assoc current-token haskell-indentation-type-list)))
@@ -1167,7 +1167,7 @@ the current buffer."
11671167
(match-string-no-properties 1))
11681168
((looking-at "[][(){}[,;]")
11691169
(match-string-no-properties 0))
1170-
((looking-at "\\(\\\\\\|->\\|=>\\|\\|<-\\|←\\|::\\|∷\\|=\\||\\)\\([^-:!#$%&*+./<=>?@\\\\^|~]\\|$\\)")
1170+
((looking-at "\\(\\\\\\|->\\|→\\|<-\\|←\\|::\\|∷\\|=\\||\\)\\([^-:!#$%&*+./<=>?@\\\\^|~]\\|$\\)")
11711171
(match-string-no-properties 1))
11721172
((looking-at "\\(→\\|←\\|∷\\)\\([^-:!#$%&*+./<=>?@\\\\^|~]\\|$\\)")
11731173
(let ((tok (match-string-no-properties 1)))

tests/haskell-indentation-tests.el

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,27 +198,31 @@ Example of lines:
198198

199199
(ert-deftest haskell-indentation-check-17a ()
200200
"A type for a function"
201+
:expected-result :failed
201202
(haskell-indentation-check
202203
"fun :: Int"
203204
" -> Int"
204205
" ^"))
205206

206207
(ert-deftest haskell-indentation-check-17b ()
207208
"A type for a function with context"
209+
:expected-result :failed
208210
(haskell-indentation-check
209211
"fun :: Monad m"
210212
" => Int"
211213
" ^"))
212214

213215
(ert-deftest haskell-indentation-check-17c ()
214216
"A type for a function with complicated context"
217+
:expected-result :failed
215218
(haskell-indentation-check
216219
"fun :: (Monad m, MonadBaseControl IO m, MyMonad (A v) m)"
217220
" => MyMonad (A v) m"
218221
" ^"))
219222

220223
(ert-deftest haskell-indentation-check-17d ()
221224
"A type for a function with param and a complicated context"
225+
:expected-result :failed
222226
(haskell-indentation-check
223227
"fun :: (Monad m, MonadBaseControl IO m, MyMonad (A v) m)"
224228
" => MyMonad (A v) m"
@@ -302,3 +306,17 @@ Example of lines:
302306
" let "
303307
" z = 5"
304308
" ^"))
309+
310+
(ert-deftest haskell-indentation-check-instance-20a ()
311+
"instance declaration"
312+
(haskell-indentation-check
313+
"instance C a where"
314+
" c = undefined"
315+
" ^"))
316+
317+
(ert-deftest haskell-indentation-check-instance-20b ()
318+
"instance declaration"
319+
(haskell-indentation-check
320+
"instance (Monad m) => C m a where"
321+
" c = undefined"
322+
" ^"))

0 commit comments

Comments
 (0)