Giter VIP home page Giter VIP logo

autofix-ghc's Introduction

autofix-ghc

Yet another warning auto-fixer for GHC compilations with the following properties:

  • Build system independent - can work with anything that emits GHC to stdout.
  • Does not try to compile or fully parse the HS file. It doesn't depend on any Haskell parsing library (see End note about this).
  • Can show a unidiff of proposed changes (-d).
  • Can fix in place (-f).
  • It's very fast.

Also, it is very limited. Currently only fixes a single type of warning, but an annoying one about redundant imports:

src/Main.hs:34:1: Warning:
    The import of ‘forM_, forM’ from module ‘Control.Monad’ is redundant

Quick HowTo

If you fully trust the thing:

cabal clean
cabal build 2> warnings.txt
cat warnings.txt | autofix-ghc --fix

A more elaborate HowTo

Support you saved the above warning to warnings.txt by redirecting cabal output somehow.

$ cat warnings.txt | autofix-ghc --fix

autofix-ghc can fix: src/Main.hs

You can see a diff:

$ cat warnings.txt | autofix-ghc --diff

autofix-ghc can fix: src/Lib/Git.hs
diff -urN src/Main.hs src/Main.hs
--- src/Main.hs
+++ src/Main.hs
@@ -31,7 +31,7 @@
   ) where
 
 ------------------------------------------------------------------------------------
-import           Control.Monad             (forM_, forM, when)
+import           Control.Monad             (when)
 import           Control.Lens.Operators    ((&))
 import           Control.Monad.IO.Class    (liftIO)
 import           Control.Monad.Catch       (MonadMask)

And you can fix it:

$ cat warnings.txt | autofix-ghc --fix

autofix-ghc fixed: src/Main.hs

End note

I wrote this in a day for teaching myself attoparsec. If you find this useful and want to improve it, pull requests are welcomed.

autofix-ghc's People

Contributors

da-x avatar

Watchers

 avatar  avatar  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.