Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Haskell code prettifier
Haskell

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
src
tests
.ghci
.gitignore
.travis.yml
LICENSE
README.markdown
Setup.hs
stylish-haskell.cabal

README.markdown

stylish-haskell

Build Status

Introduction

A simple Haskell code prettifier. The goal is not to format all of the code in a file, since I find those kind of tools often "get in the way". However, manually cleaning up import statements etc. gets tedious very quickly.

This tool tries to help where necessary without getting in the way.

You can install it using cabal install stylish-haskell.

Features

  • Aligns and sorts import statements
  • Groups and wraps {-# LANGUAGE #-} pragmas
  • Removes trailing whitespace
  • Replaces tabs by four spaces (note that this is turned off by default)

Feature requests are welcome! Use the issue tracker for that.

Example

Turns:

{-# LANGUAGE ViewPatterns, TemplateHaskell #-}
{-# LANGUAGE GeneralizedNewtypeDeriving,
            ViewPatterns,
    ScopedTypeVariables #-}

module Bad where

import Control.Applicative ((<$>))
import System.Directory (doesFileExist)

import qualified Data.Map as M
import      Data.Map    ((!), keys, Map)   

into:

{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables        #-}
{-# LANGUAGE TemplateHaskell            #-}
{-# LANGUAGE ViewPatterns               #-}

module Bad where

import           Control.Applicative ((<$>))
import           System.Directory    (doesFileExist)

import           Data.Map            (Map, keys, (!))
import qualified Data.Map            as M

VIM integration

Since it works as a filter it is pretty easy to integrate this with VIM. Just call

:%!stylish-haskell

or add a keybinding for it.

Something went wrong with that request. Please try again.