importify 1.0 → 1.0.1
raw patch · 4 files changed
+139/−30 lines, 4 files
Files
- CHANGES.md +5/−0
- README.md +97/−0
- importify.cabal +21/−15
- test/hspec/Test/Cache.hs +16/−15
+ CHANGES.md view
@@ -0,0 +1,5 @@+1.0.1+=====++* [#79](https://github.com/serokell/importify/issues/18):+ Remove hard-coded gold linker from `.cabal` file.
+ README.md view
@@ -0,0 +1,97 @@+# importify — manage Haskell imports quickly++[](https://travis-ci.org/serokell/importify)+[](https://hackage.haskell.org/package/importify)+[](http://stackage.org/nightly/package/importify)+[](http://stackage.org/lts/package/importify)+[](https://codeclimate.com/github/serokell/importify)+[](https://opensource.org/licenses/MIT)++## _Importify_ in a nutshell.++`importify` tool helps you to manage the import section of your Haskell project modules.+GHC compiler can warn you about unused imports, and it's a good practice to remove such+imports immediately. But this becomes tedious, especially if you use explicit import lists.++_Importify_ can remove unused imports automatically.++Before importify | After importify+:---------------:|:-----------------:+ | ++You can use [`stylish-haskell`](https://github.com/jaspervdj/stylish-haskell) after `importify` to prettify imports.++In the future, we plan for _Importify_ to be able to:++ + Add missing imports automatically, so you won't have to manage+ imports manually at all.+ + Implement a cache server with the following features:+ + Download caches for Hackage packages to speed up _Importify_ runs.+ + Upload your caches for yet-to-be-published FOSS projects to+ make it easier to collaborate.+ + Query mappings from any module of every package to symbols+ exported by it to write your refactoring tools.+ + Convert imports between _implicit_ and _explicit_, and between+ _qualified_ and _unqualified_ forms.+ + Resolve merge conflicts in import section automatically. See an+ example of [such conflict](http://i.imgur.com/97YVCFk.png).++## Installation++Installation process assumes that you have already installed and configured `stack`+build tool. Currently `importify` works only with projects built with `stack`.++### Installing from Stackage++Install just as every usual package.++```bash+stack install importify+```++### Installing from source++Perform the next steps before driving:++```bash+git clone https://github.com/serokell/importify.git # 1. Clone repository locally+cd importify # 2. Step into folder+stack install importify\:exe\:importify # 3. Copy executable under ~/.local/bin+```++## Usage++In short:++```bash+$ cd my-project-which-build-with-stack+$ importify cache+$ importify file path/to/File/With/Unused/Imports.hs+```++`importify` has several commands. Most important is++```+importify --help+```++Before removing redundant imports run `importify cache`+command. Importify stores local cache for the project under the+`.importify` folder inside your project. This cache stores exported+entities for each module for every dependency and for all your local+packages. Make sure to re-run `importify cache` if you change the list+of exported functions and types in your project modules. Cache is+built incrementally; it builds dependencies only once. But if you add+dependencies or use other versions of them (for instance, because of+bumping stack lts) you need to run `importify cache` again. You can+always perform `rm -rf .importify` before caching if you face any+troubles.++After the cache is built, you can use `importify file PATH_TO_FILE`+command from your project root directory. This command runs+_Importify_ on the file and prints the result in the terminal. If you+want to change a file in-place use the following command:++```+importify file -i PATH_TO_FILE+```
importify.cabal view
@@ -1,5 +1,5 @@ name: importify-version: 1.0+version: 1.0.1 synopsis: Tool for haskell imports refactoring description: Please see README.md homepage: https://github.com/serokell/importify@@ -11,10 +11,12 @@ copyright: 2017 Serokell category: Development, Refactoring build-type: Simple-cabal-version: >=1.10+cabal-version: >=1.18 tested-with: GHC == 8.0.1 , GHC == 8.0.2- , GHC == 8.2.1+ , GHC == 8.2.2+extra-doc-files: CHANGES.md+ , README.md source-repository head type: git@@ -85,10 +87,11 @@ , yaml ghc-options: -Wall- if os(linux)- ghc-options: -optl-fuse-ld=gold- ld-options: -fuse-ld=gold +-- if os(linux)+-- ghc-options: -optl-fuse-ld=gold+-- ld-options: -fuse-ld=gold+ default-language: Haskell2010 default-extensions: GeneralizedNewtypeDeriving LambdaCase@@ -108,10 +111,11 @@ , universum >= 1.0.0 ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall- if os(linux)- ghc-options: -optl-fuse-ld=gold- ld-options: -fuse-ld=gold +-- if os(linux)+-- ghc-options: -optl-fuse-ld=gold+-- ld-options: -fuse-ld=gold+ default-language: Haskell2010 default-extensions: GeneralizedNewtypeDeriving NoImplicitPrelude@@ -129,10 +133,11 @@ , universum >= 1.0.0 ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall- if os(linux)- ghc-options: -optl-fuse-ld=gold- ld-options: -fuse-ld=gold +-- if os(linux)+-- ghc-options: -optl-fuse-ld=gold+-- ld-options: -fuse-ld=gold+ default-language: Haskell2010 test-suite importify-test@@ -153,9 +158,10 @@ , unordered-containers ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall- if os(linux)- ghc-options: -optl-fuse-ld=gold- ld-options: -fuse-ld=gold++-- if os(linux)+-- ghc-options: -optl-fuse-ld=gold+-- ld-options: -fuse-ld=gold default-language: Haskell2010 default-extensions: GeneralizedNewtypeDeriving
test/hspec/Test/Cache.hs view
@@ -6,18 +6,19 @@ ( modulesMapSpec ) where -import Universum+import Universum -import qualified Data.HashMap.Strict as HM-import Lens.Micro.Platform (at, (?=))-import Path (fromAbsFile, mkRelFile, (</>))-import Path.IO (getCurrentDir)+import Lens.Micro.Platform (at, (?=))+import Path (fromAbsFile, mkRelFile, (</>))+import Path.IO (getCurrentDir) -import Test.Hspec (Spec, describe, it, runIO, shouldSatisfy)+import Test.Hspec (Spec, describe, it, runIO, shouldSatisfy) -import Importify.Cabal (ModulesBundle (..), ModulesMap, TargetId (..))-import Importify.Path (decodeFileOrMempty, importifyPath, modulesPath)+import Importify.Cabal (ModulesBundle (..), ModulesMap, TargetId (..))+import Importify.Path (decodeFileOrMempty, importifyPath, modulesPath) +import qualified Data.HashMap.Strict as HM+ -- | 'Spec' for modules mapping. modulesMapSpec :: Spec modulesMapSpec = do@@ -33,19 +34,19 @@ let withDir path = fromAbsFile $ curDir </> path return $ executingState mempty $ do at (withDir $(mkRelFile "src/Importify/Path.hs")) ?= -- Simple file from library- ModulesBundle "importify-1.0" "Importify.Path" LibraryId+ ModulesBundle "importify-1.0.1" "Importify.Path" LibraryId at (withDir $(mkRelFile "src/Importify/Main.hs")) ?= -- autoexported file- ModulesBundle "importify-1.0" "Importify.Main" LibraryId+ ModulesBundle "importify-1.0.1" "Importify.Main" LibraryId at (withDir $(mkRelFile "src/Extended/Data/List.hs")) ?= -- file from other-modules- ModulesBundle "importify-1.0" "Extended.Data.List" LibraryId+ ModulesBundle "importify-1.0.1" "Extended.Data.List" LibraryId at (withDir $(mkRelFile "app/Main.hs")) ?= -- Main file from executable- ModulesBundle "importify-1.0" "Main" (ExecutableId "importify")+ ModulesBundle "importify-1.0.1" "Main" (ExecutableId "importify") at (withDir $(mkRelFile "app/Options.hs")) ?= -- other file from executable- ModulesBundle "importify-1.0" "Options" (ExecutableId "importify")+ ModulesBundle "importify-1.0.1" "Options" (ExecutableId "importify") at (withDir $(mkRelFile "test/hspec/Runner.hs")) ?= -- Main file for tests- ModulesBundle "importify-1.0" "Main" (TestSuiteId "importify-test")+ ModulesBundle "importify-1.0.1" "Main" (TestSuiteId "importify-test") at (withDir $(mkRelFile "test/hspec/Test/File.hs")) ?= -- Other file from tests- ModulesBundle "importify-1.0" "Test.File" (TestSuiteId "importify-test")+ ModulesBundle "importify-1.0.1" "Test.File" (TestSuiteId "importify-test") -- | @testMap `subsetOf` cacheMap@ returns 'True' iff all entries from