Coder Social home page Coder Social logo

flip111 / fix-imports Goto Github PK

View Code? Open in Web Editor NEW

This project forked from elaforge/fix-imports

0.0 0.0 0.0 394 KB

Automatically add and delete imports in a Haskell module.

License: BSD 3-Clause "New" or "Revised" License

Shell 0.98% Haskell 97.69% Vim Script 1.33%

fix-imports's Introduction

fix-imports is a small standalone program to manage the import block of a haskell program. It will try to add import lines for qualified names with no corresponding import, remove unused import lines, and keep the import block sorted, with optional rules for grouping.

Support for unqualified imports is limited to symbols you explicitly configure, so if you list System.FilePath ((</>)), it will add that import when you use it, or remove when it's no longer used, but it won't go search modules for unqualified imports.

It doesn't mess with non-managed unqualified imports, so you can still use unqualified imports, you just have to do it manually.

Since it's a unix-style filter, it should be possible to integrate into any editor. There's an example vimrc to bind to a key in vim.

Usage:

Normally you would integrate it with your editor (see vimrc for a vim example), but for testing, here's an example invocation:

fix-imports -i src -i test src/A/B/C.hs <src/A/B/C.hs
[ fixed contents of A/B/C.hs, or an error ]

The -i flag is like ghc's -i flag, it will add an aditional root to the module search path. The example will find modules in both test/* and src/*, in addition to the package db.

fix-imports will look for .ghc.environment.* in the current directory and use it for pkgs to search. This is created by cabal v2, but only if you have write-ghc-environment-files: always in cabal.project. Otherwise, it assumes cabal v1 and will use the ghc-pkg command to use the global package db.

If it doesn't seem to see packages you think it should, run with --debug to see what it sees.

I don't use stack, but my understanding is this is enough to get ghc-pkg working:

export GHC_PACKAGE_PATH=$(stack path --ghc-package-path)

fix-imports's People

Contributors

elaforge avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.