Apply brittany to Main.hs
parent
bd10c3c4ef
commit
033fdc6517
|
@ -57,8 +57,7 @@ data WriteMode = Display | Inplace
|
||||||
|
|
||||||
instance Read WriteMode where
|
instance Read WriteMode where
|
||||||
readPrec = val "display" Display <|> val "inplace" Inplace
|
readPrec = val "display" Display <|> val "inplace" Inplace
|
||||||
where
|
where val iden v = ReadPrec.lift $ ReadP.string iden >> return v
|
||||||
val iden v = ReadPrec.lift $ ReadP.string iden >> return v
|
|
||||||
|
|
||||||
instance Show WriteMode where
|
instance Show WriteMode where
|
||||||
show Display = "display"
|
show Display = "display"
|
||||||
|
@ -226,13 +225,14 @@ mainCmdParser helpDesc = do
|
||||||
$ trace (showConfigYaml config)
|
$ trace (showConfigYaml config)
|
||||||
$ return ()
|
$ return ()
|
||||||
|
|
||||||
results <- zipWithM (coreIO putStrErrLn config (suppressOutput || checkMode))
|
results <- zipWithM
|
||||||
|
(coreIO putStrErrLn config (suppressOutput || checkMode))
|
||||||
inputPaths
|
inputPaths
|
||||||
outputPaths
|
outputPaths
|
||||||
|
|
||||||
if checkMode
|
if checkMode
|
||||||
then when (any (==Changes) (Data.Either.rights results)) $
|
then when (any (== Changes) (Data.Either.rights results))
|
||||||
System.Exit.exitWith (System.Exit.ExitFailure 1)
|
$ System.Exit.exitWith (System.Exit.ExitFailure 1)
|
||||||
else case results of
|
else case results of
|
||||||
xs | all Data.Either.isRight xs -> pure ()
|
xs | all Data.Either.isRight xs -> pure ()
|
||||||
[Left x] -> System.Exit.exitWith (System.Exit.ExitFailure x)
|
[Left x] -> System.Exit.exitWith (System.Exit.ExitFailure x)
|
||||||
|
@ -278,8 +278,7 @@ coreIO putErrorLnIO config suppressOutput inputPathM outputPathM =
|
||||||
viaDebug =
|
viaDebug =
|
||||||
config & _conf_debug & _dconf_roundtrip_exactprint_only & confUnpack
|
config & _conf_debug & _dconf_roundtrip_exactprint_only & confUnpack
|
||||||
|
|
||||||
let
|
let cppCheckFunc dynFlags = if GHC.xopt GHC.Cpp dynFlags
|
||||||
cppCheckFunc dynFlags = if GHC.xopt GHC.Cpp dynFlags
|
|
||||||
then case cppMode of
|
then case cppMode of
|
||||||
CPPModeAbort -> do
|
CPPModeAbort -> do
|
||||||
return $ Left "Encountered -XCPP. Aborting."
|
return $ Left "Encountered -XCPP. Aborting."
|
||||||
|
@ -359,8 +358,7 @@ coreIO putErrorLnIO config suppressOutput inputPathM outputPathM =
|
||||||
let hackF s = fromMaybe s $ TextL.stripPrefix
|
let hackF s = fromMaybe s $ TextL.stripPrefix
|
||||||
(TextL.pack "-- BRITANY_INCLUDE_HACK ")
|
(TextL.pack "-- BRITANY_INCLUDE_HACK ")
|
||||||
s
|
s
|
||||||
let
|
let out = TextL.toStrict $ if hackAroundIncludes
|
||||||
out = TextL.toStrict $ if hackAroundIncludes
|
|
||||||
then
|
then
|
||||||
TextL.intercalate (TextL.pack "\n")
|
TextL.intercalate (TextL.pack "\n")
|
||||||
$ fmap hackF
|
$ fmap hackF
|
||||||
|
|
Loading…
Reference in New Issue