on master help sign in
Drop ‘yaml’ configuration
commitc201862f119fff67623f80e72f078ae9fe7ad8a9 authormrkkrp <mark.karpov@tweag.io> dateSun 7 Jul 2019, 12:29 (7 years ago) parentd63eeea
3 files changed+3−38
app/Main.hs+2−16 ormolu.cabal−2 src/Ormolu/Config.hs+1−20
app/Main.hs+2−16
@@ -15,21 +15,15 @@ import Paths_ormolu (version)
1515import System.Exit (ExitCode (..), exitWith)
1616import System.IO (hPutStrLn, stderr)
1717import qualified Data.Text.IO as TIO
18−import qualified Data.Yaml as Yaml
1918
2019-- | Entry point of the program.
2120
2221main :: IO ()
2322main = withPrettyOrmoluExceptions $ do
2423 Opts {..} <- execParser optsParserInfo
25− config <- case optConfigFile of
26− Nothing -> return optConfig
27− Just path -> do
28− config <- Yaml.decodeFileThrow path
29− return (config <> optConfig)
3024 r <- case optInputFile of
31− "-" -> ormoluStdin config
32− inputFile -> ormoluFile config inputFile
25+ "-" -> ormoluStdin optConfig
26+ inputFile -> ormoluFile optConfig inputFile
3327 let notForStdin = do
3428 when (optInputFile == "-") $ do
3529 hPutStrLn
@@ -58,8 +52,6 @@ main = withPrettyOrmoluExceptions $ do
5852data Opts = Opts
5953 { optMode :: !Mode
6054 -- ^ Mode of operation
61− , optConfigFile :: !(Maybe FilePath)
62− -- ^ Location of configuration file (optional)
6355 , optConfig :: !Config
6456 -- ^ Ormolu 'Config'
6557 , optInputFile :: !FilePath
@@ -107,12 +99,6 @@ optsParser = Opts
10799 , value Stdout
108100 , help "Mode of operation: 'stdout', 'inplace', or 'check'"
109101 ]
110− <*> (optional . strOption . mconcat)
111− [ long "config"
112− , short 'c'
113− , metavar "CONFIG"
114− , help "Location of configuration file"
115− ]
116102 <*> configParser
117103 <*> (strArgument . mconcat)
118104 [ metavar "FILE"
ormolu.cabal−2
@@ -47,7 +47,6 @@ library
4747 , mtl >= 2.0 && < 3.0
4848 , syb >= 0.7 && < 0.8
4949 , text >= 0.2 && < 1.3
50− , yaml >= 0.8 && < 0.12
5150 exposed-modules: Ormolu
5251 , Ormolu.Config
5352 , Ormolu.Diff
@@ -126,7 +125,6 @@ executable ormolu
126125 , optparse-applicative >= 0.14 && < 0.15
127126 , ormolu
128127 , text >= 0.2 && < 1.3
129− , yaml >= 0.8 && < 0.12
130128 other-modules: Paths_ormolu
131129 if flag(dev)
132130 ghc-options: -Wall -Werror -Wcompat
src/Ormolu/Config.hs+1−20
@@ -12,7 +12,6 @@ module Ormolu.Config
1212 )
1313where
1414
15−import Data.Yaml
1615import qualified SrcLoc as GHC
1716
1817-- | Ormolu configuration.
@@ -26,24 +25,6 @@ data Config = Config
2625 -- ^ Output information useful for debugging
2726 } deriving (Eq, Show)
2827
29−instance Semigroup Config where
30− a <> b = Config
31− { cfgDynOptions = cfgDynOptions a <> cfgDynOptions b
32− , cfgUnsafe = cfgUnsafe a || cfgUnsafe b
33− , cfgDebug = cfgDebug a || cfgDebug b
34− }
35−
36−instance Monoid Config where
37− mempty = defaultConfig
38− mappend = (<>)
39−
40−instance FromJSON Config where
41− parseJSON = withObject "config" $ \o -> do
42− cfgDynOptions <- o .: "ghc-opts"
43− cfgUnsafe <- o .: "unsafe"
44− cfgDebug <- o .: "debug"
45− return Config {..}
46−
4728-- | Default 'Config'.
4829
4930defaultConfig :: Config
@@ -57,7 +38,7 @@ defaultConfig = Config
5738
5839newtype DynOption = DynOption
5940 { unDynOption :: String
60− } deriving (Eq, Ord, Show, FromJSON)
41+ } deriving (Eq, Ord, Show)
6142
6243-- | Convert 'DynOption' to @'GHC.Located' 'String'@.
6344