Skip to content

haskell-align-imports doesn't work as advertised #183

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 Jul 16, 2013 · 7 comments
Closed

haskell-align-imports doesn't work as advertised #183

hvr opened this issue Jul 16, 2013 · 7 comments
Assignees

Comments

@hvr
Copy link
Member

hvr commented Jul 16, 2013

According to the commentary,

import One
import Two as A
import qualified Three
import qualified Four as PRELUDE
import Five (A)
import Six (A,B)
import qualified Seven (A,B)
import "abc" Eight
import "abc" Nine as TWO
import qualified "abc" Ten
import qualified "defg" Eleven as PRELUDE
import "barmu" Twelve (A)
import "zotconpop" Thirteen (A,B)
import qualified "z" Fourteen (A,B)
import Fifteen hiding (A)
import Sixteen as TWO hiding (A)
import qualified Seventeen hiding (A)
import qualified Eighteen as PRELUDE hiding (A)
import "abc" Nineteen hiding (A)
import "abc" Twenty as TWO hiding (A)

is supposed to be transformed into

import                  One
import                  Two       as A
import qualified        Three
import qualified        Four      as PRELUDE
import                  Five      (A)
import                  Six       (A,B)
import qualified        Seven     (A,B)
import "abc"            Eight
import "abc"            Nine      as TWO
import qualified "abc"  Ten
import qualified "defg" Eleven    as PRELUDE
import "barmu"          Twelve    (A)
import "zotconpop"      Thirteen  (A,B)
import qualified "z"    Fourteen  (A,B)
import                  Fifteen   hiding (A)
import                  Sixteen   as TWO hiding (A)
import qualified        Seventeen hiding (A)
import qualified        Eighteen  as PRELUDE hiding (A)
import "abc"            Nineteen  hiding (A)
import "abc"            Twenty    as TWO hiding (A)

However, the current implementation only aligns the module names:

import                  One
import                  Two as A
import qualified        Three
import qualified        Four as PRELUDE
import                  Five (A)
import                  Six (A,B)
import qualified        Seven (A,B)
import "abc"            Eight
import "abc"            Nine as TWO
import qualified "abc"  Ten
import qualified "defg" Eleven as PRELUDE
import "barmu"          Twelve (A)
import "zotconpop"      Thirteen (A,B)
import qualified "z"    Fourteen (A,B)
import                  Fifteen hiding (A)
import                  Sixteen as TWO hiding (A)
import qualified        Seventeen hiding (A)
import qualified        Eighteen as PRELUDE hiding (A)
import "abc"            Nineteen hiding (A)
import "abc"            Twenty as TWO hiding (A)
@ghost ghost assigned chrisdone Jul 16, 2013
@chrisdone
Copy link
Member

Yeah, I know it.

@hvr
Copy link
Member Author

hvr commented Jul 16, 2013

I vaguely remember, that this used to work long time ago... did something change?

@chrisdone
Copy link
Member

At some point it stopped working but I was too busy to investigate why.

@chrisdone chrisdone added the bug label May 10, 2014
@brendanhay
Copy link

FYI this version works as advertised.

@chrisdone
Copy link
Member

Here is a fix. After looking into it and testing the behaviour on some real code, I remember why I disabled this intentionally. Padding after the module name quickly becomes obnoxious when module names are long and qualification is used, you end up with floating "as" that really dangle by themselves. Similar to how you can align -> in a case but sometimes it just looks stupid and judgment is needed.

But I've enabled an option to support that again as haskell-align-imports-pad-after-name and updated the documentation.

@brendanhay
Copy link

Excellent, thanks alot.

@gracjan
Copy link
Contributor

gracjan commented Jan 18, 2015

Can this be closed?

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

No branches or pull requests

4 participants