Skip to content

Commit ae2a55b

Browse files
committed
Merge pull request #1047 from gracjan/pr-record-tibell
Record indentation should follow tibell style
2 parents 2ba5d29 + f0a0c87 commit ae2a55b

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

haskell-indentation.el

+13-13
Original file line numberDiff line numberDiff line change
@@ -646,18 +646,16 @@ For example
646646

647647
(defun haskell-indentation-data ()
648648
"Parse data or type declaration."
649-
(haskell-indentation-with-starter
650-
(lambda ()
651-
(when (string= current-token "instance")
652-
(haskell-indentation-read-next-token))
653-
(haskell-indentation-type)
654-
(cond ((string= current-token "=")
655-
(haskell-indentation-with-starter
656-
(apply-partially #'haskell-indentation-separated
657-
#'haskell-indentation-type "|" "deriving")))
658-
((string= current-token "where")
659-
(haskell-indentation-with-starter
660-
#'haskell-indentation-expression-layout nil))))))
649+
(haskell-indentation-read-next-token)
650+
(when (string= current-token "instance")
651+
(haskell-indentation-read-next-token))
652+
(haskell-indentation-type)
653+
(cond ((string= current-token "=")
654+
(haskell-indentation-separated
655+
#'haskell-indentation-expression "|" "deriving"))
656+
((string= current-token "where")
657+
(haskell-indentation-with-starter
658+
#'haskell-indentation-expression-layout nil))))
661659

662660
(defun haskell-indentation-import ()
663661
"Parse import declaration."
@@ -927,7 +925,9 @@ layout starts."
927925
(cond ((member current-token '(layout-item ";"))
928926
(haskell-indentation-read-next-token))
929927
((eq current-token 'end-tokens)
930-
(when (or (haskell-indentation-expression-token-p following-token)
928+
(when (or (and
929+
(not (string= following-token "{"))
930+
(haskell-indentation-expression-token-p following-token))
931931
(string= following-token ";")
932932
(and (equal layout-indent 0)
933933
(member following-token (mapcar #'car haskell-indentation-toplevel-list))))

tests/haskell-indentation-tests.el

+4-6
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ macro quotes them for you."
135135
function = Record
136136
{ field = 123 }"
137137
(1 0)
138-
(2 0 2))
138+
(2 2))
139139

140140
(hindent-test "2 Handle underscore in identifiers""
141141
function = do
@@ -522,7 +522,7 @@ data Foo = Foo {
522522
(1 0)
523523
(2 2)
524524
(3 2)
525-
(4 4 11))
525+
(4 11))
526526

527527
(hindent-test "21c* \"data\" declaration open on next line" "
528528
data Foo = Foo
@@ -644,7 +644,7 @@ instance Bar Int
644644
(hindent-test "32 allow type operators" "
645645
data (:.) a b = a :. b
646646
"
647-
(2 0 16))
647+
(2 0 2))
648648

649649
(hindent-test "33* parse #else in CPP" "
650650
#ifdef FLAG
@@ -661,9 +661,7 @@ data T = T {
661661
}
662662
663663
"
664-
;; set of answers isn't best but it is not a bug
665-
;; should be just 0
666-
(5 0 9))
664+
(5 0 2))
667665

668666
(hindent-test "35 baroque construct which causes parse error" "
669667
az = Projection

0 commit comments

Comments
 (0)