@@ -495,6 +495,7 @@ fixes up only indentation."
495495 (" type" . haskell-indentation-data)
496496 (" newtype" . haskell-indentation-data)
497497 (" import" . haskell-indentation-import)
498+ (" where" . haskell-indentation-toplevel-where)
498499 (" class" . haskell-indentation-class-declaration)
499500 (" instance" . haskell-indentation-class-declaration))
500501 " Alist of toplevel keywords with associated parsers." )
@@ -684,21 +685,32 @@ For example
684685 " Parse module declaration."
685686 (haskell-indentation-with-starter
686687 (lambda ()
687- (let ((current-indent (current-column )))
688- (haskell-indentation-read-next-token)
689- (when (string= current-token " (" )
690- (haskell-indentation-list
691- #'haskell-indentation-module-export
692- " )" " ," ))
693- (when (eq current-token 'end-tokens )
694- (haskell-indentation-add-indentation current-indent)
695- (throw 'parse-end nil ))
696- (when (string= current-token " where" )
688+ (haskell-indentation-read-next-token)
689+ (when (string= current-token " (" )
690+ (haskell-indentation-list
691+ #'haskell-indentation-module-export
692+ " )" " ," ))
693+ (if (string= current-token " where" )
697694 (haskell-indentation-read-next-token)
698- (when (eq current-token 'end-tokens )
699- (haskell-indentation-add-layout-indent)
695+
696+ (when (eq current-token 'end-tokens )
697+ (when (member following-token '(value no-following-token " (" ))
698+ (haskell-indentation-add-indentation
699+ (+ starter-indent haskell-indentation-starter-offset))
700+ (haskell-indentation-add-indentation
701+ (+ left-indent haskell-indentation-starter-offset))
700702 (throw 'parse-end nil ))
701- (haskell-indentation-layout #'haskell-indentation-toplevel ))))))
703+ (haskell-indentation-add-layout-indent)
704+ (throw 'parse-end nil ))))))
705+
706+ (defun haskell-indentation-toplevel-where ()
707+ " Parse 'where' that we may hit as a standalone in module
708+ declaration."
709+ (haskell-indentation-read-next-token)
710+
711+ (when (eq current-token 'end-tokens )
712+ (haskell-indentation-add-layout-indent)
713+ (throw 'parse-end nil )))
702714
703715(defun haskell-indentation-module-export ()
704716 " Parse export list."
@@ -938,7 +950,8 @@ layout starts."
938950 (haskell-indentation-expression-token-p following-token))
939951 (string= following-token " ;" )
940952 (and (equal layout-indent 0 )
941- (member following-token (mapcar #'car haskell-indentation-toplevel-list))))
953+ (member following-token (mapcar #'car haskell-indentation-toplevel-list))
954+ (not (string= following-token " where" ))))
942955 (haskell-indentation-add-layout-indent))
943956 (throw 'return nil ))
944957 (t (throw 'return nil ))))))
0 commit comments