[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

@ -16,18 +16,18 @@ parseArgs =
execParser opts execParser opts
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
@ -55,73 +55,73 @@ logLevelParser =
where where
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
<$> outputOptsSpec <$> outputOptsSpec
<*> 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
{- {-
@ -160,7 +160,7 @@ 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

@ -41,119 +41,120 @@ commandsSpec :: Parser GhcModCommands
commandsSpec = commandsSpec =
hsubparser hsubparser
$ command "lang" $ command "lang"
$$ info (pure CmdLang) $$ info (pure CmdLang)
$$ progDesc "List all known GHC language extensions" $$ progDesc "List all known GHC language extensions"
<> command "flag" <> command "flag"
$$ info (pure CmdFlag) $$ info (pure CmdFlag)
$$ progDesc "List GHC -f<foo> flags" $$ progDesc "List GHC -f<foo> flags"
<> command "debug" <> command "debug"
$$ info (pure CmdDebug) $$ info (pure CmdDebug)
$$ progDesc $$ progDesc
"Print debugging information. Please include the output in any bug\ "Print debugging information. Please include the output in any bug\
\ reports you submit" \ reports you submit"
<> command "debug-component" <> command "debug-component"
$$ info debugComponentArgSpec $$ info debugComponentArgSpec
$$ progDesc "Debugging information related to cabal component resolution" $$ progDesc "Debugging information related to cabal component resolution"
<> 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
"Try to find the project directory. For Cabal projects this is the\ "Try to find the project directory. For Cabal projects this is the\
\ directory containing the cabal file, for projects that use a cabal\ \ directory containing the cabal file, for projects that use a cabal\
\ sandbox but have no cabal file this is the directory containing the\ \ sandbox but have no cabal file this is the directory containing the\
\ cabal.sandbox.config file and otherwise this is the current\ \ cabal.sandbox.config file and otherwise this is the current\
\ directory" \ directory"
<> command "legacy-interactive" <> command "legacy-interactive"
$$ info (pure CmdLegacyInteractive) $$ info (pure CmdLegacyInteractive)
$$ progDesc "ghc-modi compatibility mode" $$ progDesc "ghc-modi compatibility mode"
<> command "list" <> command "list"
$$ info modulesArgSpec $$ info modulesArgSpec
$$ progDesc "List all visible modules" $$ progDesc "List all visible modules"
<> command "modules" <> command "modules"
$$ info modulesArgSpec $$ info modulesArgSpec
$$ progDesc "List all visible modules" $$ progDesc "List all visible modules"
<> command "dumpsym" <> command "dumpsym"
$$ info dumpSymArgSpec idm $$ info dumpSymArgSpec idm
<> command "find" <> command "find"
$$ info findArgSpec $$ info findArgSpec
$$ progDesc "List all modules that define SYMBOL" $$ progDesc "List all modules that define SYMBOL"
<> command "doc" <> command "doc"
$$ info docArgSpec $$ info docArgSpec
$$ progDesc "Try finding the html documentation directory for the given MODULE" $$ progDesc "Try finding the html documentation directory for the given MODULE"
<> command "lint" <> command "lint"
$$ info lintArgSpec $$ info lintArgSpec
$$ progDesc "Check files using `hlint'" $$ progDesc "Check files using `hlint'"
<> command "browse" <> command "browse"
$$ info browseArgSpec $$ info browseArgSpec
$$ 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
\ but don't produce output files" "Load the given files using GHC and report errors/warnings,\
\ but don't produce output files"
<> command "expand" <> command "expand"
$$ info expandArgSpec $$ info expandArgSpec
$$ progDesc "Like `check' but also pass `-ddump-splices' to GHC" $$ progDesc "Like `check' but also pass `-ddump-splices' to GHC"
<> command "info" <> command "info"
$$ info infoArgSpec $$ info infoArgSpec
$$ progDesc $$ progDesc
"Look up an identifier in the context of FILE (like ghci's `:info')\ "Look up an identifier in the context of FILE (like ghci's `:info')\
\ MODULE is completely ignored and only allowed for backwards\ \ MODULE is completely ignored and only allowed for backwards\
\ compatibility" \ compatibility"
<> command "type" <> command "type"
$$ info typeArgSpec $$ info typeArgSpec
$$ progDesc "Get the type of the expression under (LINE,COL)" $$ progDesc "Get the type of the expression under (LINE,COL)"
<> command "split" <> command "split"
$$ 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"
, "f x = _body" , "f x = _body"
]
, text "would be replaced by:"
, code [
"f :: [a] -> a"
, "f [] = _body"
, "f (x:xs) = _body"
]
, text "(See https://github.com/kazu-yamamoto/ghc-mod/pull/274)"
] ]
, text "would be replaced by:"
, code [
"f :: [a] -> a"
, "f [] = _body"
, "f (x:xs) = _body"
]
, text "(See https://github.com/kazu-yamamoto/ghc-mod/pull/274)"
]
<> 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)"]
, text "ghc-mod would add the following on the next line:" , text "ghc-mod would add the following on the next line:"
, code ["func x y z f = _func_body"] , code ["func x y z f = _func_body"]
, text "(See: https://github.com/kazu-yamamoto/ghc-mod/pull/274)" , text "(See: https://github.com/kazu-yamamoto/ghc-mod/pull/274)"
] ]
<> command "auto" <> command "auto"
$$ info autoArgSpec $$ info autoArgSpec
$$ progDesc "Try to automatically fill the contents of a hole" $$ progDesc "Try to automatically fill the contents of a hole"
<> 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:"
, code [ , code [
"filterNothing :: [Maybe a] -> [a]" "filterNothing :: [Maybe a] -> [a]"
, "filterNothing xs = _body" , "filterNothing xs = _body"
] ]
, text "ghc-mod changes the code to get a value of type `[a]', which\ , text "ghc-mod changes the code to get a value of type `[a]', which\
\ results in:" \ results in:"
, code [ "filterNothing xs = filter _body_1 _body_2" ] , code [ "filterNothing xs = filter _body_1 _body_2" ]
, text "(See also: https://github.com/kazu-yamamoto/ghc-mod/issues/311)" , text "(See also: https://github.com/kazu-yamamoto/ghc-mod/issues/311)"
] ]
strArg :: String -> Parser String strArg :: String -> Parser String
strArg = argument str . metavar strArg = argument str . metavar
@ -176,32 +177,32 @@ 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
(<$$>) = (<$>) (<$$>) = (<$>)