[Optparse] s/##/<=>/g

This commit is contained in:
Nikolay Yakimov 2015-12-06 21:30:03 +03:00
parent 67cabf3cdf
commit 01e1a83c25
3 changed files with 163 additions and 162 deletions

View File

@ -17,17 +17,17 @@ parseArgs =
where where
opts = info (argAndCmdSpec <**> helpVersion) opts = info (argAndCmdSpec <**> helpVersion)
$$ fullDesc $$ fullDesc
## header "ghc-mod: Happy Haskell Programming" <=> header "ghc-mod: Happy Haskell Programming"
helpVersion :: Parser (a -> a) helpVersion :: Parser (a -> a)
helpVersion = helpVersion =
helper helper
<*> abortOption (InfoMsg ghcModVersion) <*> abortOption (InfoMsg ghcModVersion)
$$ long "version" $$ long "version"
## help "Print the version of the program." <=> help "Print the version of the program."
<*> argument r <*> argument r
$$ value id $$ value id
## metavar "" <=> metavar ""
where where
r :: ReadM (a -> a) r :: ReadM (a -> a)
r = do r = do
@ -56,61 +56,61 @@ logLevelParser =
logLevelOption = logLevelOption =
option int option int
$$ long "verbose" $$ long "verbose"
## metavar "LEVEL" <=> metavar "LEVEL"
## value 4 <=> value 4
## showDefault <=> showDefault
## help "Set log level. (0-7)" <=> help "Set log level. (0-7)"
logLevelSwitch = logLevelSwitch =
(4+) . length <$> many $$ flag' () (4+) . length <$> many $$ flag' ()
$$ short 'v' $$ short 'v'
## help "Increase log level" <=> help "Increase log level"
silentSwitch = flag' 0 silentSwitch = flag' 0
$$ long "silent" $$ long "silent"
## short 's' <=> short 's'
## help "Be silent, set log level to 0" <=> help "Be silent, set log level to 0"
outputOptsSpec :: Parser OutputOpts outputOptsSpec :: Parser OutputOpts
outputOptsSpec = OutputOpts outputOptsSpec = OutputOpts
<$> logLevelParser <$> logLevelParser
<*> flag PlainStyle LispStyle <*> flag PlainStyle LispStyle
$$ long "tolisp" $$ long "tolisp"
## short 'l' <=> short 'l'
## help "Format output as an S-Expression" <=> help "Format output as an S-Expression"
<*> LineSeparator <$$> strOption <*> LineSeparator <$$> strOption
$$ long "boundary" $$ long "boundary"
## long "line-separator" <=> long "line-separator"
## short 'b' <=> short 'b'
## metavar "SEP" <=> metavar "SEP"
## value "\0" <=> value "\0"
## showDefault <=> showDefault
## help "Output line separator" <=> help "Output line separator"
<*> optional $$ splitOn ',' <$$> strOption <*> optional $$ splitOn ',' <$$> strOption
$$ long "line-prefix" $$ long "line-prefix"
## metavar "OUT,ERR" <=> metavar "OUT,ERR"
## help "Output prefixes" <=> help "Output prefixes"
programsArgSpec :: Parser Programs programsArgSpec :: Parser Programs
programsArgSpec = Programs programsArgSpec = Programs
<$> strOption <$> strOption
$$ long "with-ghc" $$ long "with-ghc"
## value "ghc" <=> value "ghc"
## showDefault <=> showDefault
## help "GHC executable to use" <=> help "GHC executable to use"
<*> strOption <*> strOption
$$ long "with-ghc-pkg" $$ long "with-ghc-pkg"
## value "ghc-pkg" <=> value "ghc-pkg"
## showDefault <=> showDefault
## help "ghc-pkg executable to use (only needed when guessing from GHC path fails)" <=> help "ghc-pkg executable to use (only needed when guessing from GHC path fails)"
<*> strOption <*> strOption
$$ long "with-cabal" $$ long "with-cabal"
## value "cabal" <=> value "cabal"
## showDefault <=> showDefault
## help "cabal-install executable to use" <=> help "cabal-install executable to use"
<*> strOption <*> strOption
$$ long "with-stack" $$ long "with-stack"
## value "stack" <=> value "stack"
## showDefault <=> showDefault
## help "stack executable to use" <=> help "stack executable to use"
globalArgSpec :: Parser Options globalArgSpec :: Parser Options
globalArgSpec = Options globalArgSpec = Options
@ -118,10 +118,10 @@ globalArgSpec = Options
<*> programsArgSpec <*> programsArgSpec
<*> many $$ strOption <*> many $$ strOption
$$ long "ghcOpt" $$ long "ghcOpt"
## long "ghc-option" <=> long "ghc-option"
## short 'g' <=> short 'g'
## metavar "OPT" <=> metavar "OPT"
## help "Option to be passed to GHC" <=> help "Option to be passed to GHC"
<*> many fileMappingSpec <*> many fileMappingSpec
where where
{- {-
@ -161,6 +161,6 @@ globalArgSpec = Options
fileMappingSpec = fileMappingSpec =
getFileMapping . splitOn '=' <$> strOption getFileMapping . splitOn '=' <$> strOption
$$ long "map-file" $$ long "map-file"
## metavar "MAPPING" <=> metavar "MAPPING"
## help "Redirect one file to another, --map-file \"file1.hs=file2.hs\"" <=> help "Redirect one file to another, --map-file \"file1.hs=file2.hs\""
getFileMapping = second (\i -> if null i then Nothing else Just i) getFileMapping = second (\i -> if null i then Nothing else Just i)

View File

@ -57,8 +57,8 @@ commandsSpec =
<> command "boot" <> command "boot"
$$ info (pure CmdBoot) $$ info (pure CmdBoot)
$$ progDesc "Internal command used by the emacs frontend" $$ progDesc "Internal command used by the emacs frontend"
-- <> command "nuke-caches" ( -- <> command "nuke-caches"
-- info (pure CmdNukeCaches) idm) -- $$ info (pure CmdNukeCaches) idm
<> command "root" <> command "root"
$$ info (pure CmdRoot) $$ info (pure CmdRoot)
$$ progDesc $$ progDesc
@ -92,7 +92,8 @@ commandsSpec =
$$ progDesc "List symbols in a module" $$ progDesc "List symbols in a module"
<> command "check" <> command "check"
$$ info checkArgSpec $$ info checkArgSpec
$$ progDesc "Load the given files using GHC and report errors/warnings,\ $$ progDesc
"Load the given files using GHC and report errors/warnings,\
\ but don't produce output files" \ but don't produce output files"
<> command "expand" <> command "expand"
$$ info expandArgSpec $$ info expandArgSpec
@ -110,7 +111,7 @@ commandsSpec =
$$ info splitArgSpec $$ info splitArgSpec
$$ progDesc $$ progDesc
"Split a function case by examining a type's constructors" "Split a function case by examining a type's constructors"
## desc [ <=> desc [
text "For example given the following code snippet:" text "For example given the following code snippet:"
, code [ , code [
"f :: [a] -> a" "f :: [a] -> a"
@ -127,7 +128,7 @@ commandsSpec =
<> command "sig" <> command "sig"
$$ info sigArgSpec $$ info sigArgSpec
$$ progDesc "Generate initial code given a signature" $$ progDesc "Generate initial code given a signature"
## desc [ <=> desc [
text "For example when (LINE,COL) is on the signature in the following\ text "For example when (LINE,COL) is on the signature in the following\
\ code snippet:" \ code snippet:"
, code ["func :: [a] -> Maybe b -> (a -> b) -> (a,b)"] , code ["func :: [a] -> Maybe b -> (a -> b) -> (a,b)"]
@ -141,7 +142,7 @@ commandsSpec =
<> command "refine" <> command "refine"
$$ info refineArgSpec $$ info refineArgSpec
$$ progDesc "Refine the typed hole at (LINE,COL) given EXPR" $$ progDesc "Refine the typed hole at (LINE,COL) given EXPR"
## desc [ <=> desc [
text "For example if EXPR is `filter', which has type `(a -> Bool) -> [a]\ text "For example if EXPR is `filter', which has type `(a -> Bool) -> [a]\
\ -> [a]' and (LINE,COL) is on the hole `_body' in the following\ \ -> [a]' and (LINE,COL) is on the hole `_body' in the following\
\ code snippet:" \ code snippet:"
@ -177,31 +178,31 @@ modulesArgSpec, dumpSymArgSpec, docArgSpec, findArgSpec,
modulesArgSpec = CmdModules modulesArgSpec = CmdModules
<$> switch <$> switch
$$ long "detailed" $$ long "detailed"
## short 'd' <=> short 'd'
## help "Print package modules belong to" <=> help "Print package modules belong to"
dumpSymArgSpec = CmdDumpSym <$> strArg "TMPDIR" dumpSymArgSpec = CmdDumpSym <$> strArg "TMPDIR"
findArgSpec = CmdFind <$> strArg "SYMBOL" findArgSpec = CmdFind <$> strArg "SYMBOL"
docArgSpec = CmdDoc <$> strArg "MODULE" docArgSpec = CmdDoc <$> strArg "MODULE"
lintArgSpec = CmdLint lintArgSpec = CmdLint
<$> LintOpts <$$> many $$ strOption <$> LintOpts <$$> many $$ strOption
$$ long "hlintOpt" $$ long "hlintOpt"
## short 'h' <=> short 'h'
## help "Option to be passed to hlint" <=> help "Option to be passed to hlint"
<*> strArg "FILE" <*> strArg "FILE"
browseArgSpec = CmdBrowse browseArgSpec = CmdBrowse
<$> (BrowseOpts <$> (BrowseOpts
<$> switch <$> switch
$$ long "operators" $$ long "operators"
## short 'o' <=> short 'o'
## help "Also print operators" <=> help "Also print operators"
<*> switch <*> switch
$$ long "detailed" $$ long "detailed"
## short 'd' <=> short 'd'
## help "Print symbols with accompanying signature" <=> help "Print symbols with accompanying signature"
<*> switch <*> switch
$$ long "qualified" $$ long "qualified"
## short 'q' <=> short 'q'
## help "Qualify symbols" <=> help "Qualify symbols"
) )
<*> some (strArg "MODULE") <*> some (strArg "MODULE")
debugComponentArgSpec = filesArgsSpec CmdDebugComponent debugComponentArgSpec = filesArgsSpec CmdDebugComponent

View File

@ -3,7 +3,7 @@ module GHCMod.Options.DocUtils (
desc, desc,
code, code,
($$), ($$),
(##), (<=>),
(<$$>), (<$$>),
(<||>) (<||>)
) where ) where
@ -21,7 +21,7 @@ code x = vsep [line, indent 4 $ vsep $ map text x, line]
infixl 7 <||> infixl 7 <||>
infixr 8 <$$> infixr 8 <$$>
infixr 8 $$ infixr 8 $$
infixr 9 ## infixr 9 <=>
($$) :: (a -> b) -> a -> b ($$) :: (a -> b) -> a -> b
($$) = ($) ($$) = ($)
@ -29,8 +29,8 @@ infixr 9 ##
(<||>) :: Alternative a => a b -> a b -> a b (<||>) :: Alternative a => a b -> a b -> a b
(<||>) = (<|>) (<||>) = (<|>)
(##) :: Monoid m => m -> m -> m (<=>) :: Monoid m => m -> m -> m
(##) = (<>) (<=>) = (<>)
(<$$>) :: Functor f => (a -> b) -> f a -> f b (<$$>) :: Functor f => (a -> b) -> f a -> f b
(<$$>) = (<$>) (<$$>) = (<$>)