Skip to content

Instantly share code, notes, and snippets.

@JustusAdam
Created July 21, 2015 07:39
Show Gist options
  • Save JustusAdam/1e6ed19c3dc83c2710ff to your computer and use it in GitHub Desktop.
Save JustusAdam/1e6ed19c3dc83c2710ff to your computer and use it in GitHub Desktop.
Let stylish-haskell loose on a directory and all its subdirectories.
{-# LANGUAGE UnicodeSyntax #-}
module StyleAll where
import Control.Monad
import Control.Monad.Unicode
import Data.Bool
import Prelude.Unicode
import System.Directory
import System.Environment
import System.FilePath
import System.Process
styleCmd = callCommand ∘ ("stylish-haskell -i " ⧺)
handleOne file =
doesFileExist file ≫=
bool
(getDirectoryContents file ≫= mapM_ (handleOne ∘ (file </>)) ∘ filter (not ∘ (∈ [".", ".."])) )
(when (takeExtension file ∈ [".hs", ".lhs"]) $ styleCmd file)
main =
getArgs ≫= mapM_ handleOne
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment