Skip to content

add (+ tab-width) indentation proposals #571

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
wants to merge 1 commit into from

Conversation

s9gf4ult
Copy link

@s9gf4ult s9gf4ult commented Apr 4, 2015

This adds indentation proposals on (+ tab-indent)

for example, if you write

newtype SessionId = SessionId

then default indentation proposals would be

newtype SessionId = SessionId
{ getSessionId :: Text

or

newtype SessionId = SessionId
                    { getSessionId :: Text

this patch adds also

newtype SessionId = SessionId
    { getSessionId :: Text

and

newtype SessionId = SessionId
                        { getSessionId :: Text

variants to indent.

In fact, it just duplicates (+ tab-width) for each found indentation proposal.

Unfortunately my code is hackish and this feature might be done better.

@gracjan
Copy link
Contributor

gracjan commented Apr 4, 2015

Related #366.

@gracjan
Copy link
Contributor

gracjan commented Apr 4, 2015

Thanks for tackling this one. This is important feature.

Having said that I think it should be done a indentation style setting. Either tab-width is important or alignment is important, not both.

Rationale:

Indentation in Haskell is mostly deterministic except in a couple of places when a layout block ends. Keeping it as deterministic as possible will enable us to have a sane indent-region.

Your commit as it is now would increase non-determinism, which is a very sad trade off to take.

@s9gf4ult
Copy link
Author

s9gf4ult commented Apr 4, 2015

This patch is very stupid and code in haskell-indentation.el is too complicated to understand it in measurable time. I think this patch is the best I can offer.

Or you just mean that I must use haskell-indentation-layout-offset (or some other setting) instead of tab-width ?

@gracjan
Copy link
Contributor

gracjan commented Apr 4, 2015

Your patch is an important vote for shallow indentation. Thanks.

There is a place in the code where indentation offset for the { is calculated. Can you find it?

@s9gf4ult
Copy link
Author

s9gf4ult commented Apr 5, 2015

Well, there is many places where { pattern occures in code. haskell-indentation.el has very very complex code. To do this patch I just grepped possible-indentations defined in haskell-indentation-parse-to-indentations assuming it is a list of posible indentation positions. I found one such place, which is function haskell-indentation-push-indentation, then I modified this function and trick worked.

Code in haskell-indentation.el is not very functional-style, everything mutates everything, it is very complex to understand. We need someone who knows how all this works to make this feature right.

@gracjan
Copy link
Contributor

gracjan commented Apr 5, 2015

That is why current project focus is lowering the entry barrier for new users, new issue reporters and first time contributors and the goal is 100 haskell-mode contributors.

We need to leave after us a maintainable piece of software. I've started doing this by writing some unit tests like in #562.

While you tried to hack on haskell-indentation you have learned a lot already. Can you document your knowledge in the form ofo unit tests, comments or refactorings?

@s9gf4ult
Copy link
Author

s9gf4ult commented Apr 6, 2015

Well, I will try, but can not promise anything usefull.

@gracjan
Copy link
Contributor

gracjan commented Apr 6, 2015 via email

@gracjan
Copy link
Contributor

gracjan commented Apr 6, 2015

I'm closing this PR with strong conviction that #366 is the way to go.

@gracjan gracjan closed this Apr 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants