File tree Expand file tree Collapse file tree 2 files changed +37
-7
lines changed Expand file tree Collapse file tree 2 files changed +37
-7
lines changed Original file line number Diff line number Diff line change @@ -740,10 +740,7 @@ the current buffer."
740
740
(" where" .
741
741
,(apply-partially 'haskell-indentation-with-starter
742
742
'haskell-indentation-declaration-layout nil t ))
743
- (" ::" .
744
- ,(apply-partially 'haskell-indentation-with-starter
745
- (apply-partially #'haskell-indentation-separated
746
- #'haskell-indentation-type " ->" )))
743
+ (" ::" . haskell-indentation-scoped-type)
747
744
(" =" .
748
745
,(apply-partially 'haskell-indentation-statement-right
749
746
'haskell-indentation-expression ))
@@ -834,6 +831,17 @@ After a lambda (backslash) there are two possible cases:
834
831
(throw 'return nil )
835
832
(funcall (cdr parser))))))))))
836
833
834
+ (defun haskell-indentation-scoped-type ()
835
+ " Parse scoped type declaration.
836
+
837
+ For example
838
+ let x :: Int = 12
839
+ do x :: Int <- return 12"
840
+ (haskell-indentation-with-starter
841
+ (apply-partially #'haskell-indentation-separated #'haskell-indentation-type " ->" ))
842
+ (when (member current-token '(" <-" " =" ))
843
+ (haskell-indentation-statement-right #'haskell-indentation-expression )))
844
+
837
845
(defun haskell-indentation-data ()
838
846
" Parse data or type declaration."
839
847
(haskell-indentation-with-starter
Original file line number Diff line number Diff line change @@ -524,15 +524,37 @@ func = 1234
524
524
-}"
525
525
((3 2 ) 0 ))
526
526
527
- (hindent-test " 24* should parse inline type signatures properly" "
527
+ (hindent-test " 24 should parse inline type signatures properly" "
528
528
foo = do
529
529
_ :: String <- undefined
530
530
_ :: String <- undefined
531
531
return ()"
532
532
((1 0 ) 0 )
533
533
((2 0 ) 2 )
534
- ((3 0 ) 2 17 )
535
- ((4 0 ) 2 17 ))
534
+ ((3 0 ) 0 2 17 )
535
+ ((4 0 ) 0 2 17 ))
536
+
537
+ (hindent-test " 25a* support scoped type declarations" "
538
+ foo = do
539
+ bar :: String
540
+ -> String
541
+ <- undefined"
542
+ ((1 0 ) 0 )
543
+ ((2 0 ) 2 )
544
+ ((3 0 ) 6 9 )
545
+ ; ; here it brakes, it would like to put '<-' on same line with 'bar'
546
+ ; ; the culprit is the 'do' keyword
547
+ ((4 0 ) 4 ))
548
+
549
+ (hindent-test " 25b support scoped type declarations" "
550
+ foo = let
551
+ bar :: String
552
+ -> String
553
+ = undefined"
554
+ ((1 0 ) 0 )
555
+ ((2 0 ) 2 )
556
+ ((3 0 ) 6 9 )
557
+ ((4 0 ) 4 ))
536
558
537
559
538
560
; ;; haskell-indentation-tests.el ends here
You can’t perform that action at this time.
0 commit comments