Skip to content

Reconsider haskell-indent #1104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks
gracjan opened this issue Jan 22, 2016 · 8 comments
Closed
3 tasks

Reconsider haskell-indent #1104

gracjan opened this issue Jan 22, 2016 · 8 comments

Comments

@gracjan
Copy link
Contributor

gracjan commented Jan 22, 2016

@jstolarek made me aware of functionality in haskell-indent that is not present in haskell-indentation.

I was under the impression that haskell-indentation is evolved and improved form of haskell-indent and itself was superseeded by hi2 (later renamed back to haskell-indentation).

It does not seem to be the case.

The plan:

  • see what is different
  • find out features in haskell-indent
  • see if haskell-indent is hackable in better or similar way as haskell-indentation
@jstolarek
Copy link

In the last couple of days I realized that blaming all these indentation problems entirely on haskell-indentation might not be fair. All these problems began for me after updating Emacs 24.3.1 to 24.5.1. This switch broke behaviour of haskell-indent (#1013), which forced me to switch to haskell-indentation. But now I see that indentation behaviour has generally changed in Emacs after the update: it behaves differently than it used to in LaTeX mode and text mode as well. So it seems that latest version of Emacs has changed its behaviour when it comes to indentation.

@jstolarek
Copy link

After a few minutes of investigation I learned that since version 24.4 Emacs comes with electric-indent-mode enabled by default. Disabling it restores haskell-indent's behaviour to normal. But it doesn't seem to affect haskell-indentation in any way. For now I am happy that I can once again use haskell-indent.

@gracjan
Copy link
Contributor Author

gracjan commented Jan 27, 2016

I'm checking out haskell-indent code and this is my personal opinion so far. haskell-indent seems to be very cleanly written. It tries to find definitions and then separate definition parts so that each part may be indented according to its own indentation rules. There is a decision table and a bit of special logic here and there. Variable names are short and this does not help but then comments are to the point and clarify concepts.

There is no test suite, but it can be created.

Due to programming model with special cases for splits, decision table and other specail constructs I do not see immediately how to extend haskell-indent to support constructs in language that were created after haskell-indent was finished. Compare that haskell-indentation is a recursive descent parser that allows rather easy and schematic improvements.

There is a charm to the code so I think I'll push forward with test suite and then we will see where to take it from there.

@gracjan
Copy link
Contributor Author

gracjan commented Jan 27, 2016

haskell-indent will suggestion function after this code:

function = Record
           { field = 123 }

but not after this:

function = Record
      { field = 123 }

haskell-indent will suggest z in line after this code:

fact n = do
  z <- let x = 5
       in return (x + 4)

Looks like there are plenty of bugs here and there.

@jstolarek
Copy link

Looks like there are plenty of bugs here and there.

Good point. But TBH these bugs never bothered me too much - pressing Tab cycles to another indent alternative.

@gracjan
Copy link
Contributor Author

gracjan commented Jan 28, 2016 via email

@gracjan
Copy link
Contributor Author

gracjan commented Jan 28, 2016

I added a test suite for haskell-indent. It does not look good but it is a good start if somebody would like to take over from there.

@gracjan
Copy link
Contributor Author

gracjan commented Jul 13, 2016

Merging with #1065.

@gracjan gracjan closed this as completed Jul 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants