1
1
mirror of https://github.com/tweag/ormolu.git synced 2024-09-11 13:16:13 +03:00

Format files in parallel

There is no explicit configuration for this, but it is possible for users to
override by changing the RTS options to the `ormolu` executable.
This commit is contained in:
Michael Peyton Jones 2024-07-08 10:59:36 +01:00 committed by Mark Karpov
parent 3f2e3180d7
commit 7c6355b6df
3 changed files with 16 additions and 2 deletions

View File

@ -1,3 +1,8 @@
## Unreleased
* Format multiple files in parallel. [Issue
1128](https://github.com/tweag/ormolu/issues/1128).
## Ormolu 0.7.7.0 ## Ormolu 0.7.7.0
* Use single-line layout for parens around single-line content. [Issue * Use single-line layout for parens around single-line content. [Issue

View File

@ -33,6 +33,7 @@ import System.Directory
import System.Exit (ExitCode (..), exitWith) import System.Exit (ExitCode (..), exitWith)
import System.FilePath qualified as FP import System.FilePath qualified as FP
import System.IO (hPutStrLn, stderr) import System.IO (hPutStrLn, stderr)
import UnliftIO.Async (pooledMapConcurrently)
-- | Entry point of the program. -- | Entry point of the program.
main :: IO () main :: IO ()
@ -53,7 +54,8 @@ main = do
ExitSuccess -> Nothing ExitSuccess -> Nothing
ExitFailure n -> Just n ExitFailure n -> Just n
errorCodes <- errorCodes <-
mapMaybe selectFailure <$> mapM (formatOne' . Just) (sort xs) mapMaybe selectFailure
<$> pooledMapConcurrently (formatOne' . Just) (sort xs)
return $ return $
if null errorCodes if null errorCodes
then ExitSuccess then ExitSuccess

View File

@ -153,6 +153,14 @@ executable ormolu
ormolu, ormolu,
text >=2.1 && <3, text >=2.1 && <3,
th-env >=0.1.1 && <0.2, th-env >=0.1.1 && <0.2,
unliftio >=0.2.10 && <0.3,
-- We use parallelism so we need a threaded runtime to get any
-- benefit.
ghc-options:
-threaded
-rtsopts
-with-rtsopts=-N
if flag(dev) if flag(dev)
ghc-options: ghc-options:
@ -166,7 +174,6 @@ executable ormolu
ghc-options: ghc-options:
-O2 -O2
-Wall -Wall
-rtsopts
test-suite tests test-suite tests
type: exitcode-stdio-1.0 type: exitcode-stdio-1.0