hfmt: Haskell source code formatter

[ language, library, mit, program ] [ Propose Tags ] [ Report a vulnerability ]

Inspired by gofmt. Built using hlint, hindent, and stylish-haskell.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.0.1.0, 0.0.2.0, 0.0.2.1, 0.0.2.2, 0.0.2.3, 0.1.0, 0.1.1, 0.2.0, 0.2.1, 0.2.2, 0.2.3.0, 0.2.3.1, 0.3.0.0
Dependencies ansi-wl-pprint, base (>=4.8 && <5), bytestring, Cabal, conduit, conduit-combinators, Diff, directory, exceptions, filepath, haskell-src-exts (>1.20), hfmt, hindent (>=5 && <6), hlint (>=3 && <4), HUnit, optparse-applicative, path, path-io, pretty, stylish-haskell, text, transformers, yaml [details]
Tested with ghc ==8.0.2, ghc ==8.2.2, ghc ==8.4.2, ghc ==8.5
License MIT
Author Daniel Stiner
Maintainer Daniel Stiner <daniel.stiner@gmail.com>
Category Language
Home page https://github.com/danstiner/hfmt#readme
Bug tracker https://github.com/danstiner/hfmt/issues
Source repo head: git clone https://github.com/danstiner/hfmt
Uploaded by danielstiner at 2021-09-07T03:29:00Z
Distributions
Executables hfmt
Downloads 7853 total (21 in the last 30 days)
Rating 2.25 (votes: 2) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2021-09-07 [all 1 reports]

Readme for hfmt-0.3.0.0

[back to package description]

hfmt

Hackage license Build Status

hfmt is a tool for formatting Haskell programs. Currently it is simply a gofmt style wrapper of the excellent tools hlint, hindent, and stylish-haskell.

Installation

with stack

$ stack install hfmt

with cabal

$ cabal install hfmt

Usage

Check all Haskell source under the current directory:

hfmt

Overwrite files with formatting suggestions:

hfmt -w

Help text

λ hfmt --help
hfmt - format Haskell programs

Usage: hfmt [-d|--print-diffs] [FILE]
  Reformats Haskell source files by applying HLint, hindent, and
  stylish-haskell.

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

Exit Codes:
  0 = No error
  1 = Encountered I/O or other operational error
  2 = Failed to parse a source code file
  3 = Source code was parsed but cannot be formatted properly
  4 = Formatted code differs from existing source (--print-diffs only)