@@ -495,6 +495,7 @@ fixes up only indentation."
495
495
(" type" . haskell-indentation-data)
496
496
(" newtype" . haskell-indentation-data)
497
497
(" import" . haskell-indentation-import)
498
+ (" where" . haskell-indentation-toplevel-where)
498
499
(" class" . haskell-indentation-class-declaration)
499
500
(" instance" . haskell-indentation-class-declaration))
500
501
" Alist of toplevel keywords with associated parsers." )
@@ -684,21 +685,32 @@ For example
684
685
" Parse module declaration."
685
686
(haskell-indentation-with-starter
686
687
(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" )
697
694
(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))
700
702
(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 )))
702
714
703
715
(defun haskell-indentation-module-export ()
704
716
" Parse export list."
@@ -938,7 +950,8 @@ layout starts."
938
950
(haskell-indentation-expression-token-p following-token))
939
951
(string= following-token " ;" )
940
952
(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" ))))
942
955
(haskell-indentation-add-layout-indent))
943
956
(throw 'return nil ))
944
957
(t (throw 'return nil ))))))
0 commit comments