Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions haskell-indentation.el
Original file line number Diff line number Diff line change
Expand Up @@ -646,18 +646,16 @@ For example

(defun haskell-indentation-data ()
"Parse data or type declaration."
(haskell-indentation-with-starter
(lambda ()
(when (string= current-token "instance")
(haskell-indentation-read-next-token))
(haskell-indentation-type)
(cond ((string= current-token "=")
(haskell-indentation-with-starter
(apply-partially #'haskell-indentation-separated
#'haskell-indentation-type "|" "deriving")))
((string= current-token "where")
(haskell-indentation-with-starter
#'haskell-indentation-expression-layout nil))))))
(haskell-indentation-read-next-token)
(when (string= current-token "instance")
(haskell-indentation-read-next-token))
(haskell-indentation-type)
(cond ((string= current-token "=")
(haskell-indentation-separated
#'haskell-indentation-expression "|" "deriving"))
((string= current-token "where")
(haskell-indentation-with-starter
#'haskell-indentation-expression-layout nil))))

(defun haskell-indentation-import ()
"Parse import declaration."
Expand Down Expand Up @@ -927,7 +925,9 @@ layout starts."
(cond ((member current-token '(layout-item ";"))
(haskell-indentation-read-next-token))
((eq current-token 'end-tokens)
(when (or (haskell-indentation-expression-token-p following-token)
(when (or (and
(not (string= following-token "{"))
(haskell-indentation-expression-token-p following-token))
(string= following-token ";")
(and (equal layout-indent 0)
(member following-token (mapcar #'car haskell-indentation-toplevel-list))))
Expand Down
10 changes: 4 additions & 6 deletions tests/haskell-indentation-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ macro quotes them for you."
function = Record
{ field = 123 }"
(1 0)
(2 0 2))
(2 2))

(hindent-test "2 Handle underscore in identifiers""
function = do
Expand Down Expand Up @@ -522,7 +522,7 @@ data Foo = Foo {
(1 0)
(2 2)
(3 2)
(4 4 11))
(4 11))

(hindent-test "21c* \"data\" declaration open on next line" "
data Foo = Foo
Expand Down Expand Up @@ -644,7 +644,7 @@ instance Bar Int
(hindent-test "32 allow type operators" "
data (:.) a b = a :. b
"
(2 0 16))
(2 0 2))

(hindent-test "33* parse #else in CPP" "
#ifdef FLAG
Expand All @@ -661,9 +661,7 @@ data T = T {
}

"
;; set of answers isn't best but it is not a bug
;; should be just 0
(5 0 9))
(5 0 2))

(hindent-test "35 baroque construct which causes parse error" "
az = Projection
Expand Down