packages feed

hfmt 0.0.2.1 → 0.0.2.2

raw patch · 3 files changed

+65/−17 lines, 3 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

+ README.md view
@@ -0,0 +1,47 @@+## hfmt [![Build Status](https://travis-ci.org/danstiner/hfmt.svg?branch=master)](https://travis-ci.org/danstiner/hfmt)
+
+hfmt is a tool for formatting Haskell programs. Currently it is simply a gofmt style wrapper of the excellent tools [hlint](https://github.com/ndmitchell/hlint/blob/master/README.md), [hindent](https://github.com/chrisdone/hindent#readme), and [stylish-haskell](https://github.com/jaspervdj/stylish-haskell#readme).
+
+
+## Installation
+
+    $ cabal install hfmt
+
+## Usage
+
+Check all Haskell source in the current directory:
+
+    hfmt
+
+Overwrite any files with formatting changes:
+
+    hfmt -w
+
+## Help text
+
+    λ hfmt --help
+    hfmt - format Haskell programs
+
+    Usage: hfmt.exe [-d|--print-diffs] [-s|--print-sources] [-l|--print-paths]
+                    [-w|--write-sources] [PATH]
+      Operates on Haskell source files, reformatting them by applying suggestions
+      from HLint, hindent, and stylish-haskell. Inspired by the gofmt utility.
+
+    Available options:
+      -h,--help                Show this help text
+      -d,--print-diffs         If a file's formatting is different, print a diff.
+      -s,--print-sources       If a file's formatting is different, print its
+                               source.
+      -l,--print-paths         If a file's formatting is different, print its path.
+      -w,--write-sources       If a file's formatting is different, overwrite it.
+      PATH                     Explicit paths to process.
+                                - A single '-' will process standard input.
+                                - Files will be processed directly.
+                                - Directories will be recursively searched for
+                                  source files to process.
+                                - .cabal files will be parsed and all specified
+                                  source directories and files processed.
+                                - If no paths are given, the current directory will
+                                  be searched for .cabal files to process, if none
+                                  are found the current directory will be
+                                  recursively searched for source files to process.
hfmt.cabal view
@@ -1,5 +1,5 @@ name:                hfmt
-version:             0.0.2.1
+version:             0.0.2.2
 synopsis:            Haskell source code formatter
 description:         Inspired by gofmt. Built using hlint, hindent, and stylish-haskell.
 license:             MIT
@@ -11,8 +11,9 @@ bug-reports:         http://github.com/danstiner/hfmt/issues
 category:            Language
 build-type:          Simple
+extra-source-files:  README.md
 cabal-version:       >=1.9.2
-tested-with:         GHC==7.8.4, GHC==7.10.2, GHC == 7.11.*
+tested-with:         GHC >= 7.10
 
 library
   Hs-Source-Dirs:    src
@@ -25,9 +26,8 @@                      , Language.Haskell.Format.HLint
                      , Language.Haskell.Format.Stylish
   GHC-Options:       -Wall
-  Build-Depends:     base == 4.*
+  Build-Depends:     base >= 4.8 && < 5
                      , Cabal
-                     , Diff
                      , directory
                      , filepath
                      , haskell-src-exts
@@ -35,7 +35,6 @@                      , hlint >= 1.9.13 , hlint < 2
                      , HUnit
                      , pipes
-                     , pretty
                      , stylish-haskell
                      , text
 
src/Language/Haskell/Format/HLint.hs view
@@ -1,29 +1,31 @@ module Language.Haskell.Format.HLint (autoSettings, formatter, suggester) where
 
-import Language.Haskell.Format.Definitions
-import Language.Haskell.Format.Internal
+import           Language.Haskell.Format.Definitions
+import           Language.Haskell.Format.Internal
 
-import Control.Applicative
-import Language.Haskell.Exts.Annotated     as Hse
-import Language.Haskell.HLint3             hiding (autoSettings)
+import           Control.Applicative
+import           Language.Haskell.Exts.Annotated     as Hse
+import qualified Language.Haskell.HLint3             as HLint3
 
 formatter = undefined
 
-suggester :: (ParseMode, [Classify], Hint) -> Formatter
+suggester :: (ParseMode, [HLint3.Classify], HLint3.Hint) -> Formatter
 suggester = mkSuggester . hlint
 
-hlint :: (ParseMode, [Classify], Hint) -> HaskellSource -> Either String [Suggestion]
+hlint :: (ParseMode, [HLint3.Classify], HLint3.Hint) -> HaskellSource -> Either String [Suggestion]
 hlint (parseMode, classifications, hint) (HaskellSource source) =
   getSuggestions <$> parseResultAsEither (parse source)
   where
     parse = Hse.parseFileContentsWithComments parseMode
-    getSuggestions moduleSource = map ideaToSuggestion $ applyHints classifications hint
+    getSuggestions moduleSource = map ideaToSuggestion $ HLint3.applyHints classifications hint
                                                            [moduleSource]
 
-autoSettings :: IO (ParseMode, [Classify], Hint)
+autoSettings :: IO (ParseMode, [HLint3.Classify], HLint3.Hint)
 autoSettings = do
-  (fixities, classify, hints) <- findSettings (readSettingsFile Nothing) Nothing
-  return (hseFlags (parseFlagsAddFixities fixities defaultParseFlags), classify, resolveHints hints)
+  (fixities, classify, hints) <- HLint3.findSettings (HLint3.readSettingsFile Nothing) Nothing
+  return
+    (HLint3.hseFlags (HLint3.parseFlagsAddFixities fixities HLint3.defaultParseFlags), classify, HLint3.resolveHints
+                                                                                                   hints)
 
 parseResultAsEither :: ParseResult a -> Either String a
 parseResultAsEither (ParseOk a) = Right a
@@ -34,5 +36,5 @@     filename = "[" ++ srcFilename loc ++ "]"
     linecol = "(" ++ show (srcLine loc) ++ ":" ++ show (srcColumn loc) ++ ")"
 
-ideaToSuggestion :: Idea -> Suggestion
+ideaToSuggestion :: HLint3.Idea -> Suggestion
 ideaToSuggestion = Suggestion . show