-
Notifications
You must be signed in to change notification settings - Fork 347
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
Comments
Can you add a specific example? |
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, sayHello :: IO ()
sayHello = do
name <- getLine
putStrLn $ greeting name
where
greeting name = "Hello, " ++ name ++ "!" |
The |
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. |
@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. |
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 |
I also prefer something similar to gibiansky's style. 4 spaces takes too much space IMO. |
I use 2 spaces indent almost everywhere including Haskell. |
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. |
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. |
“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. |
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'. |
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 |
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. |
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'swhich 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... :-)
The text was updated successfully, but these errors were encountered: