Skip to content

Default indentation mode ought to support and use Johan Tibell's style by default #1042

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
hvr opened this issue Dec 30, 2015 · 14 comments
Closed

Comments

@hvr
Copy link
Member

hvr commented Dec 30, 2015

IMO, if we do impose a default indentation mode in haskell-mode which seems to be the case recently, this mode should be close to @tibbe's

which is commonly used as basis for project-specific style conventions such as e.g.

Afaics, this indentation style seems to be the most popular style currently. In fact, I recommend beginners and students to follow that proven style rather than wasting time inventing their own style, and I'm sure I'm not the only one pointing people to that style guide... :-)

@gracjan
Copy link
Contributor

gracjan commented Dec 30, 2015

Can you add a specific example?

@hvr
Copy link
Member Author

hvr commented Dec 30, 2015

For one, when setting

(setq haskell-indentation-layout-offset 4
        haskell-indentation-left-offset 4
        haskell-indentation-ifte-offset 4)

I can't seem to be able to properly indent the hanging where-clause from the style-guide example:

sayHello :: IO ()
sayHello = do
    name <- getLine
    putStrLn $ greeting name
  where
    greeting name = "Hello, " ++ name ++ "!"

Instead, haskell-mode insists to indent the where-clause with two additional spaces, i.e. as

sayHello :: IO ()
sayHello = do
    name <- getLine
    putStrLn $ greeting name
  where
      greeting name = "Hello, " ++ name ++ "!"

@gracjan
Copy link
Contributor

gracjan commented Jan 1, 2016

The greeting word is 4 spaces from w in where.

@gracjan
Copy link
Contributor

gracjan commented Jan 2, 2016

Using:

(setq haskell-indentation-layout-offset 4
      haskell-indentation-starter-offset 4
      haskell-indentation-left-offset 4
      haskell-indentation-ifte-offset 4
      haskell-indentation-where-pre-offset 2
      haskell-indentation-where-post-offset 2)

gives you what you want, tibell style. But then there are too many knobs for my taste, anyway.

@PierreR
Copy link
Contributor

PierreR commented Jan 2, 2016

@hvr Imposing a 4 space indentation is what I personally dislike in Tibbe's style ;-)

I mainly use gibiansky's for this reason and I occasionally customize it to be closer to ekmett's style.

IMHO saying that a 4 space indentation style is idiomatic isn't true (just look at ekmett's source). That said I mainly love Tibbe's style but I feel it is quite a shame it goes as far as imposing 4 over 2 space indentation. Readability wise, it doesn't matter that much.

@gracjan
Copy link
Contributor

gracjan commented Jan 3, 2016

I find gibiansky's style confusing, half of the examples on that writeup use 4 space indents although the style claims 2 spaces is correct.

I would put ekmett's style along with ekmett on the extraordinary users shelf. Mortal beings should not write such condensed code.

@wedens
Copy link

wedens commented Jan 3, 2016

I also prefer something similar to gibiansky's style. 4 spaces takes too much space IMO.

@geraldus
Copy link
Contributor

geraldus commented Jan 3, 2016

I use 2 spaces indent almost everywhere including Haskell.

@mrkkrp
Copy link
Contributor

mrkkrp commented Jan 6, 2016

Indentation step should be easily customizable, it's not correct approach to hard-code it, because for social reasons, there will always be people who would like to chagne it whatever value you choose as default.

Presonally, I find 2 spaces still readable and it allows to put more code on one line.

@gracjan
Copy link
Contributor

gracjan commented Jan 6, 2016

Note that every customization option introduces new dimension in testing space.

Currently our unit test cases cover a single set of seven options, the current defaults. Supporting other sets requires unit tests at least for some of those cases, otherwise we cannot claim that we support customization, can we?

Due to effort constraints we can a solid default indentation because I do not see anybody willing to write those x^7 tests that we need to somewhat cover customizations.

Note also that almost nobody changes defaults (unless defaults just do not work at all). Taking into account that customization is costly there are better ways to invest our limited resources.

@mrkkrp
Copy link
Contributor

mrkkrp commented Jan 6, 2016

“Worse is better” at work :-) In principle it's of course doable. It's possible to use parametrized code snippets for testing, so indentation levels in those snippets can be controlled. Then it should be possible to try several combinations of customized indentation parameters on every test (automatically, we already have macro-wrappers in place for those tests by the way).

Of course framework for all this stuff requires effort as well. So, as long as default is 2 spaces, I have nothing against current setup.

@gracjan
Copy link
Contributor

gracjan commented Jan 6, 2016

2 spaces is status quo at this point so it will require energy to change, energy we seem to be lacking.

I'm very surprized that so many of you optimize for character density on the screen. Haskell is already dense in meaning per character (at least compared to other languages known of their verbosity).

I could understand 2 space for a brace structured language where whitespace is just auxilary, but for Haskell, where indentation whitespace conveys structural meaning, reducing whitespace is a very strange concept. We should optimize for the case of 'glancing function control flow structure easily at te end of 10h coding session'.

@geraldus
Copy link
Contributor

geraldus commented Jan 7, 2016

Well, as for me, I use 2 spaces because I got used to (I use 2 spaces almost everywhere in other code I have to deal with). By the way, initially I've used 4 spaces for haskell code, but this changed when I wrote some amount of elisp code (also, now I'm actively use parentheses in haskell rather than $). What I want to say, that everything is changing in time.

@gracjan
Copy link
Contributor

gracjan commented Feb 22, 2016

Default indentation should support the style that is used in GHC own source code. This is the user base we would like to win over for haskell-indentation.

This is not Tibells style, sorry.

@gracjan gracjan closed this as completed Feb 22, 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

6 participants