Open
Description
Consider:
module Foo where
import Data.Monoid -- from base
import Data.List -- from base
And then:
$ stylish-haskell /tmp/Foo.hs
module Foo where
import Data.List
import Data.Monoid
$
The comments shouldn't be stripped from the end, ideally. At the very least this is inconsistent with the default behavior which will preserve comments in most other positions.
Activity
AnneTheAgile commentedon Apr 7, 2014
This seems like possibly a nice small thing I could help contribute, especially since I am often wont to add remarks about imports :).
I'd like to start with a test on my branch. Would it be right for a test to be added to each section in the imports test file? Or would I only need to add one test? (Maybe I'm asking the wrong question, possibly it depends on the implementation, which I haven't investigated yet.)
I love that you have Travis CI and tests all set up !
Notes to self;
1.I found the right place to add one or more tests, stylish-haskell/tests/Language/Haskell/Stylish/Step/Imports/Tests.hs
https://github.com/jaspervdj/stylish-haskell/blob/105a1845152876bb7c49acda190e995c64659d01/tests/Language/Haskell/Stylish/Step/Imports/Tests.hs
2.That code is really clean and easy to read.
2a.WISH Haskell had the Ruby RSpec DSL style of test namings.
3.The types of possible import configuration values are the following , taken from the config;
Import cleanup
imports: # There are different ways we can align names and lists.
# - global: Align the import names and import list throughout the entire # file.
# - file: Like global, but don't add padding when there are no qualified # imports in the file. #
# - group: Only align the imports per group (a group is formed by adjacent # import lines).
# - none: Do not perform any alignment. #
# Default: global.
align: global ## Used by SnapFramework
4.I found this project via the NYC Haskell Hackathon via my neighbor's commit,
snapframework/io-streams#24
//AnneTheAgile
jaspervdj commentedon Apr 7, 2014
I think only one test should do in this case. I'd add the test for the
global
configuration, since that is most commonly used (as far as I'm aware off). Thanks for tackling this, and let me know if you have any questions!AnneTheAgile commentedon Apr 8, 2014
thank you @jaspervdj ! I will give it a go.
AnneTheAgile commentedon Apr 22, 2014
I ginned up a test to add to the end, I think this will work but I haven't tested it yet.
Now -- #39 Allow comments after import statements.
AnneTheAgile commentedon Apr 22, 2014
Hmm, so I'm not sure where the comments are stripped out? It seems like Imports.hs relies on no-comments in a couple of places, eg counting longest import. So then maybe the comments are not parsed out in that file but rather before it gets there? Any easy hints for me? thank you!
p.s. Evie at our Haskell Cats might be able to help me out as well if there is no obvious hint to be given. http://www.meetup.com/Haskell_For_Cats/
AnneTheAgile commentedon Apr 23, 2014
Ticket #7 Treatment of long imports may help. They sought to parse;
langston-barrett commentedon Jan 20, 2017
Note that this also happens on
LANGUAGE
pragmas.becomes
{-# LANGUAGE ScopedTypeVariables #-}
andrewufrank commentedon Mar 8, 2017
i observed the same "disappearing" comments on language pragmas and import. please fix soon - is required to document! (and putting them on separate lines makes things less
stylish
thank you for a useful tool!
[-]Comments should not be stripped from the end of 'import' statements.[/-][+]Comments should not be stripped from 'import' statements[/+]neongreen commentedon Apr 15, 2017
It also happens with comments in the middle of
import
statements, e.g. #151:[-]Comments should not be stripped from 'import' statements[/-][+]Comments should not be stripped from 'import' statements and language pragmas[/+]andrewufrank commentedon May 23, 2017
any fix in sight ? - it makes it impossible to use stylish haskell with HTF testing (and HTF testing is in many projects crucial). i am sorry that i had to de-install stylish...
6 remaining items