Add import and module support #124

Merged
lspitzner merged 26 commits from import into master 2018-03-21 16:00:58 +01:00
lspitzner commented 2018-03-12 17:47:12 +01:00 (Migrated from github.com)

#83 got closed due to me deleting the dev branch, so I now reopen it, including several finishing touches.

I am planning to merge this and make a new release with it in the next days. Again, sorry for the long hold-up, but fixing the low-level bug (see below) took a good bit of time and this caused me to put this off again and again.

In addition to what was last added to #83, this branch also contains the following changes:

  • Merge in current master

  • Fix bug in lower-level parts of brittany that led to discarding certain alternatives with the IEThingWith layouters. See af7f9017b8, which is a one-liner fix, that nonetheless was rather time-consuming to diagnose.

  • Prevent hanging indent for IEThingWith. This is a bugfix for the IndentPolicyLeft case and an opinionated improvement otherwise:

    -- hanging indent:
    import Test
      ( Long( List
            , Of
            , Things
            ) )
    -- fixed version:
    import Test
      ( Long
        ( List
        , Of
        , Things
        )
      )
    
  • Retain empty lines before the module keyword that previously got eaten. Added a new BriDoc constructor just for this.

  • Add config options _lconfig_reformatModulePreamble and _lconfig_allowSingleLineExportList (defaults True and False). The former can disable preamble formatting if desired. The latter is again the question of consistency - I like my exports in separate line even if it is just one short thingy. I was so arrogant to set the default according to my preference.

  • Change _lconfig_importColumn default from 60 to 50, as was discussed in #83. I have left the test-config as-is (at 60) because I am lazy.

#83 got closed due to me deleting the `dev` branch, so I now reopen it, including several finishing touches. I am planning to merge this and make a new release with it in the next days. Again, sorry for the long hold-up, but fixing the low-level bug (see below) took a good bit of time and this caused me to put this off again and again. In addition to what was last added to #83, this branch also contains the following changes: - Merge in current master - Fix bug in lower-level parts of `brittany` that led to discarding certain alternatives with the `IEThingWith` layouters. See af7f9017b82d9fa9d8886716a7e82cd2e9854dd9, which is a one-liner fix, that nonetheless was rather time-consuming to diagnose. - Prevent hanging indent for IEThingWith. This is a bugfix for the `IndentPolicyLeft` case and an opinionated improvement otherwise: ~~~~.hs -- hanging indent: import Test ( Long( List , Of , Things ) ) -- fixed version: import Test ( Long ( List , Of , Things ) ) ~~~~ - Retain empty lines before the `module` keyword that previously got eaten. Added a new `BriDoc` constructor just for this. - Add config options `_lconfig_reformatModulePreamble` and `_lconfig_allowSingleLineExportList` (defaults `True` and `False`). The former can disable preamble formatting if desired. The latter is again the question of consistency - I like my exports in separate line even if it is just one short thingy. I was so arrogant to set the default according to my preference. - Change _lconfig_importColumn default from 60 to 50, as was discussed in #83. I have left the test-config as-is (at 60) because I am lazy.
tfausak commented 2018-03-12 19:31:02 +01:00 (Migrated from github.com)

🎉 Looks great!

cc @sniperrifle2004

:tada: Looks great! cc @sniperrifle2004
matthew-piziak commented 2018-03-20 18:25:47 +01:00 (Migrated from github.com)

Is anything blocking this PR?

Is anything blocking this PR?
lspitzner commented 2018-03-21 01:03:45 +01:00 (Migrated from github.com)

Well there is this minor-feature request, which I implemented just now.

But that made me notice this:

#test long-module-name-hiding-items
import           TestJustShortEnoughModuleNameLike hiding ( abc
                                                          , def
                                                          , ghci
                                                          , jklm
                                                          )
import           TestJustAbitToLongModuleNameLikeTh
                                                   hiding ( abc
                                                          , def
                                                          , ghci
                                                          , jklm
                                                          )

currently gives

import           TestJustShortEnoughModuleNameLike hiding ( abc
                                                   , def
                                                   , ghci
                                                   , jklm
                                                   )
import           TestJustAbitToLongModuleNameLikeTh
                                                   hiding ( abc
                                                   , def
                                                   , ghci
                                                   , jklm
                                                   )
Well there is [this minor-feature request](https://github.com/haskell/haskell-ide-engine/issues/492#issuecomment-372432953), which I implemented just now. But that made me notice this: ~~~~.hs #test long-module-name-hiding-items import TestJustShortEnoughModuleNameLike hiding ( abc , def , ghci , jklm ) import TestJustAbitToLongModuleNameLikeTh hiding ( abc , def , ghci , jklm ) ~~~~ currently gives ~~~~.hs import TestJustShortEnoughModuleNameLike hiding ( abc , def , ghci , jklm ) import TestJustAbitToLongModuleNameLikeTh hiding ( abc , def , ghci , jklm ) ~~~~
lspitzner commented 2018-03-21 01:05:50 +01:00 (Migrated from github.com)

I'll merge anyway, this feature branch has lived long enough. Presuming the CI comes out green. There will be minor stuff to fix anyway in the future I guess.

I'll merge anyway, this feature branch has lived long enough. Presuming the CI comes out green. There will be minor stuff to fix anyway in the future I guess.
matthew-piziak commented 2018-03-21 17:44:41 +01:00 (Migrated from github.com)

🎉

:tada:
domenkozar commented 2018-03-23 15:54:38 +01:00 (Migrated from github.com)

🎉

:tada:
Sign in to join this conversation.
There is no content yet.