Code folding swallows all empty lines at top level indentation
Not quite sure this is a bug or a feature, but (haskell-hide-toggle) from haskell-collapse calculates end of overlay region to the next same-level indented code, while ignoring all blank lines. I'd suggest blank lines have to be ignored only in nested indentation levels, not the initial one. The way how code is now folded, with losing all intended spacing between logically unrelated code, makes it overall less readable.
For example:
main = putStrLn $ greet ++ name -- cursor on this line
where
greet = "Hello "
name = "Alice"
topLevelFn = undefined
folds to
main = putStrLn $ greet ++ name...
topLevelFn = undefined
instead of to this
main = putStrLn $ greet ++ name...
topLevelFn = undefined
ie. with initial indentation level blank lines preserved.
Related code in (haskell-find-line-with-indentation)
https://github.com/haskell/haskell-mode/blob/bbdbc0e9231f49a45ce787ebfb3f2b019615bf61/haskell-collapse.el#L82-L84
where blank lines are skipped despite next indentation level found (or end of file).
Maybe some backtracking for last range of empty lines, by comparison of indentation levels between their preceding and the initial one ?
Yes, you might be right. I don't use folding, and can't comment on what the ideal behaviour would be. I'd imagine keeping one blank line between the folded items might be helpful, but not necessarily all of them.