Skip to content

Commit

Permalink
Format files in parallel
Browse files Browse the repository at this point in the history
There is no explicit configuration for this, but it is possible for
users to override by changing the RTS options to the `ormolu`
executable.
  • Loading branch information
michaelpj committed Jul 8, 2024
1 parent 7a334ac commit ce57fff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Unreleased

* Format multiple files in parallel. [Issue 1128](https://github.com/tweag/ormolu/issues/1128).

## Ormolu 0.7.7.0

* Use single-line layout for parens around single-line content. [Issue
Expand Down
4 changes: 3 additions & 1 deletion app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

module Main (main) where

import Control.Concurrent.Async (mapConcurrently)
import Control.Exception (throwIO)
import Control.Monad
import Data.Bool (bool)
Expand Down Expand Up @@ -53,7 +54,8 @@ main = do
ExitSuccess -> Nothing
ExitFailure n -> Just n
errorCodes <-
mapMaybe selectFailure <$> mapM (formatOne' . Just) (sort xs)
-- Format files in parallel, solves #1128
mapMaybe selectFailure <$> mapConcurrently (formatOne' . Just) (sort xs)
return $
if null errorCodes
then ExitSuccess
Expand Down
7 changes: 6 additions & 1 deletion ormolu.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ executable ormolu
default-language: GHC2021
build-depends:
Cabal-syntax >=3.12 && <3.13,
async >=2.2 && <2.3,
base >=4.12 && <5,
containers >=0.5 && <0.8,
directory ^>=1.3,
Expand All @@ -146,13 +147,17 @@ executable ormolu
text >=2.1 && <3,
th-env >=0.1.1 && <0.2

-- We use parallelism so we need a threaded runtime to get any
-- benefit.
ghc-options: -threaded -rtsopts -with-rtsopts=-N

if flag(dev)
ghc-options:
-Wall -Werror -Wredundant-constraints -Wpartial-fields
-Wunused-packages -Wwarn=unused-packages

else
ghc-options: -O2 -Wall -rtsopts
ghc-options: -O2 -Wall

test-suite tests
type: exitcode-stdio-1.0
Expand Down

0 comments on commit ce57fff

Please sign in to comment.