@@ -493,6 +493,7 @@ fixes up only indentation."
493493 (" type" . haskell-indentation-data)
494494 (" newtype" . haskell-indentation-data)
495495 (" import" . haskell-indentation-import)
496+ (" where" . haskell-indentation-toplevel-where)
496497 (" class" . haskell-indentation-class-declaration)
497498 (" instance" . haskell-indentation-class-declaration)
498499 (" deriving" . haskell-indentation-deriving))
@@ -732,21 +733,32 @@ For example
732733 " Parse module declaration."
733734 (haskell-indentation-with-starter
734735 (lambda ()
735- (let ((current-indent (current-column )))
736- (haskell-indentation-read-next-token)
737- (when (string= current-token " (" )
738- (haskell-indentation-list
739- #'haskell-indentation-module-export
740- " )" " ," ))
741- (when (eq current-token 'end-tokens )
742- (haskell-indentation-add-indentation current-indent)
743- (throw 'parse-end nil ))
744- (when (string= current-token " where" )
736+ (haskell-indentation-read-next-token)
737+ (when (string= current-token " (" )
738+ (haskell-indentation-list
739+ #'haskell-indentation-module-export
740+ " )" " ," ))
741+ (if (string= current-token " where" )
745742 (haskell-indentation-read-next-token)
746- (when (eq current-token 'end-tokens )
747- (haskell-indentation-add-layout-indent)
743+
744+ (when (eq current-token 'end-tokens )
745+ (when (member following-token '(value no-following-token " (" ))
746+ (haskell-indentation-add-indentation
747+ (+ starter-indent haskell-indentation-starter-offset))
748+ (haskell-indentation-add-indentation
749+ (+ left-indent haskell-indentation-starter-offset))
748750 (throw 'parse-end nil ))
749- (haskell-indentation-layout #'haskell-indentation-toplevel ))))))
751+ (haskell-indentation-add-layout-indent)
752+ (throw 'parse-end nil ))))))
753+
754+ (defun haskell-indentation-toplevel-where ()
755+ " Parse 'where' that we may hit as a standalone in module
756+ declaration."
757+ (haskell-indentation-read-next-token)
758+
759+ (when (eq current-token 'end-tokens )
760+ (haskell-indentation-add-layout-indent)
761+ (throw 'parse-end nil )))
750762
751763(defun haskell-indentation-module-export ()
752764 " Parse export list."
@@ -986,7 +998,8 @@ layout starts."
986998 (haskell-indentation-expression-token-p following-token))
987999 (string= following-token " ;" )
9881000 (and (equal layout-indent 0 )
989- (member following-token (mapcar #'car haskell-indentation-toplevel-list))))
1001+ (member following-token (mapcar #'car haskell-indentation-toplevel-list))
1002+ (not (string= following-token " where" ))))
9901003 (haskell-indentation-add-layout-indent))
9911004 (throw 'return nil ))
9921005 (t (throw 'return nil ))))))
0 commit comments