Skip to content
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

Add support for post qualified import formatting. #335

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jhmcstanton
Copy link
Contributor

Adds an option to use post qualified module imports.

Related to #284
Resolves #334

Let me know if any more tests or changes are needed.

Adds an option to use post qualified module imports.

Related to haskell#284
Resolves haskell#334
#
# Default: false
ghc_lib_parser: false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ghc_lib_parser option was removed since it is not used.

@jhmcstanton
Copy link
Contributor Author

Not sure what the issue is with that mac build, classic case of "works on my machine". Not sure that I have access to rerun the build though, can someone with access trigger that for me (or show me how) ?

@akrmn
Copy link
Contributor

akrmn commented Nov 19, 2020

This is exactly what I'm looking for right now.

It seems like the build error is the same one I got on #337, @jaspervdj, could we ignore it again for this PR?

@akrmn
Copy link
Contributor

akrmn commented Nov 19, 2020

hm, this seems to fail on post qualified explicit imports:

import Data.Aeson qualified as JSON (Value)

gives me:

RealSrcSpan SrcSpanOneLine "./test.hs": parse error on input `qualified'

I'll add a few failing test cases later today

@@ -62,6 +62,9 @@ tests = testGroup "Language.Haskell.Stylish.Step.Imports.Tests"
, testCase "case 28" case28
, testCase "case 29" case29
, testCase "case 30" case30
, testCase "case 31" case31
, testCase "case 32" case32
, testCase "case 33" case33
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
]
, testCase "case 34" case34
, testCase "case 35" case35
, testCase "case 36" case36
, testCase "case 37" case37
]

, ""
, "import Data.Foo (Foo (Bar, Foo), Goo (Goo))"
, "import Data.Set (empty, intersect, nub)"
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
]
]
--------------------------------------------------------------------------------
case34 :: Assertion
case34 = assertSnippet (step Nothing defaultOptions {postQualified = True})
[ "import qualified Data.Aeson as JSON (Value)"
]
[ "import Data.Aeson qualified as JSON (Value)"
]
--------------------------------------------------------------------------------
case35 :: Assertion
case35 = assertSnippet (step Nothing defaultOptions {postQualified = True})
[ "import Data.Aeson qualified as JSON (Value)"
]
[ "import Data.Aeson qualified as JSON (Value)"
]
--------------------------------------------------------------------------------
case36 :: Assertion
case36 = assertSnippet (step Nothing defaultOptions {postQualified = True})
[ "import qualified Data.Aeson as JSON (Value)"
, "import qualified Data.Aeson as JSON (encode, decode)"
]
[ "import Data.Aeson qualified as JSON (Value, decode, encode)"
]
--------------------------------------------------------------------------------
case37 :: Assertion
case37 = assertSnippet (step Nothing defaultOptions {postQualified = True})
[ "import Data.Aeson qualified as JSON (Value)"
, "import Data.Aeson qualified as JSON (encode, decode)"
]
[ "import Data.Aeson qualified as JSON (Value, decode, encode)"
]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jhmcstanton I've also added these changes as a PR to your branch, in case that's easier to work with

@EncodePanda
Copy link
Contributor

@jhmcstanton would it be much work now to rebase this against main?

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.

Format imports qualified post
3 participants