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."
740740 (" where" .
741741 ,(apply-partially 'haskell-indentation-with-starter
742742 '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)
747744 (" =" .
748745 ,(apply-partially 'haskell-indentation-statement-right
749746 'haskell-indentation-expression ))
@@ -834,6 +831,17 @@ After a lambda (backslash) there are two possible cases:
834831 (throw 'return nil )
835832 (funcall (cdr parser))))))))))
836833
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+
837845(defun haskell-indentation-data ()
838846 " Parse data or type declaration."
839847 (haskell-indentation-with-starter
Original file line number Diff line number Diff line change @@ -524,15 +524,37 @@ func = 1234
524524-}"
525525 ((3 2 ) 0 ))
526526
527- (hindent-test " 24* should parse inline type signatures properly" "
527+ (hindent-test " 24 should parse inline type signatures properly" "
528528foo = do
529529 _ :: String <- undefined
530530 _ :: String <- undefined
531531 return ()"
532532 ((1 0 ) 0 )
533533 ((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 ))
536558
537559
538560; ;; haskell-indentation-tests.el ends here
You can’t perform that action at this time.
0 commit comments