Skip to content

haskell-indentation should line up function arguments #813

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
ElectricCoffee opened this issue Aug 15, 2015 · 8 comments
Closed

haskell-indentation should line up function arguments #813

ElectricCoffee opened this issue Aug 15, 2015 · 8 comments

Comments

@ElectricCoffee
Copy link

Emacs will consistently do this: ( = the other indent point(s))

myFunction = maybe arg1
□            arg2
□            arg3

Instead of doing this:

myFunction = maybe arg1
□            □     arg2
□            □     arg3

When putting arguments on a line of their own, this could lead to some edge cases where the code gets evaluated wrong due to the indentation level not being correct

As an example:

foo = do maybe arg1
         arg2

Would be interpreted as foo = do { maybe arg1; arg2 }

While

foo = do maybe arg1
               arg2

Would be interpreted as foo = do { maybe arg1 arg2 }

@treeowl
Copy link

treeowl commented Aug 15, 2015

Aside from any concerns about layout rules, it's just not what I want, and it seems I'm not alone.

@ElectricCoffee
Copy link
Author

I posted this as an issue on StackOverflow. I got an overwhelming amount of responses saying they also had the same issue. So it seems I'm not alone either.

http://stackoverflow.com/questions/32016807/haskell-indentation-doesnt-line-up-function-arguments

The responses on SO were the motivation to open it as a ticket here

@gracjan
Copy link
Contributor

gracjan commented Aug 16, 2015

Stackoverflow question has 5 comments, one of those is 'I have the same issues', other four try to be helpful.

@ElectricCoffee
Copy link
Author

And eight upvotes.

Most people don't bother commenting on the issue, they just upvote it if they think it's a good question or if they have a similar problem

@mrkkrp
Copy link
Contributor

mrkkrp commented Aug 17, 2015

@ElectricCoffee, currently haskell-indentation-mode is a bit buggy, we all should admit that. However, I had a conversation with author of haskell-indentation and he's willing to rewrite underlying parser in clearer (and thus less-buggy) manner.

I've contributed too and haskell-indentation will have very strong collection of tests (most of them fail for now, because tests are very intensive and haskell-indentation-mode is a bit buggy, as I said), so situation will improve. If you can write Emacs Lisp, consider contributing. We all use Emacs to write Haskell, but haskell-mode has quite a few problems and needs more men.

Look at number of issues here! At the same time there are not so many active contributors, so it will not start work smoothly by itself.

@ElectricCoffee
Copy link
Author

I'd love to contribute, but unfortunately I don't know anywhere near enough Emacs lisp at the moment to provide any sort of useful contributions.

I'm glad it's being looked at at least. I'll try and contribute when I feel comfortable enough with my knowledge of how elisp and the emacs api is put together.

@gracjan gracjan changed the title haskell-indentation doesn't line up function arguments correctly haskell-indentation doesn't line up function arguments Apr 26, 2016
@gracjan gracjan changed the title haskell-indentation doesn't line up function arguments haskell-indentation should line up function arguments Apr 26, 2016
@gracjan
Copy link
Contributor

gracjan commented Apr 26, 2016

Style mentioned here seems to be mostly used in data declarations, for example in containers:

data IntMap a = Bin {-# UNPACK #-} !Prefix
                    {-# UNPACK #-} !Mask
                    !(IntMap a)
                    !(IntMap a)
              | Tip {-# UNPACK #-} !Key a
              | Nil

https://github.com/haskell/containers/blob/master/Data/IntMap/Base.hs#L277-L283

I wasn't able to find a real life example for function arguments alignment.

Note that haskell-indentation currently does not track the column of the second token in expression. This means that implementing this style requires a significant change to the algorithm.

@gracjan
Copy link
Contributor

gracjan commented Aug 12, 2016

Duplicate of #82.

@gracjan gracjan closed this as completed Aug 12, 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

4 participants