-o option to display operators, too.
This commit is contained in:
parent
5af81af272
commit
0cda133040
12
Browse.hs
12
Browse.hs
@ -10,9 +10,17 @@ import Types
|
|||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
|
|
||||||
browseModule :: Options -> String -> IO String
|
browseModule :: Options -> String -> IO String
|
||||||
browseModule opt mdlName = convert opt . validate <$> browse mdlName
|
browseModule opt mdlName = convert opt . format <$> browse mdlName
|
||||||
where
|
where
|
||||||
validate = sort . filter (isAlpha.head)
|
format
|
||||||
|
| operators opt = formatOps
|
||||||
|
| otherwise = removeOps
|
||||||
|
removeOps = sort . filter (isAlpha.head)
|
||||||
|
formatOps = sort . map formatOps'
|
||||||
|
formatOps' x@(s:_)
|
||||||
|
| isAlpha s = x
|
||||||
|
| otherwise = '(' : x ++ ")"
|
||||||
|
formatOps' [] = error "formatOps'"
|
||||||
|
|
||||||
browse :: String -> IO [String]
|
browse :: String -> IO [String]
|
||||||
browse mdlName = withGHC $ do
|
browse mdlName = withGHC $ do
|
||||||
|
12
GHCMod.hs
12
GHCMod.hs
@ -23,13 +23,13 @@ import Types
|
|||||||
usage :: String
|
usage :: String
|
||||||
usage = "ghc-mod version 0.5.1\n"
|
usage = "ghc-mod version 0.5.1\n"
|
||||||
++ "Usage:\n"
|
++ "Usage:\n"
|
||||||
++ "\t ghc-mod [-l] list\n"
|
++ "\t ghc-mod list [-l]\n"
|
||||||
++ "\t ghc-mod [-l] lang\n"
|
++ "\t ghc-mod lang [-l]\n"
|
||||||
++ "\t ghc-mod [-l] browse <module> [<module> ...]\n"
|
++ "\t ghc-mod browse [-l] [-o] <module> [<module> ...]\n"
|
||||||
++ "\t ghc-mod check <HaskellFile>\n"
|
++ "\t ghc-mod check <HaskellFile>\n"
|
||||||
++ "\t ghc-mod type <HaskellFile> <module> <expression>\n"
|
++ "\t ghc-mod type <HaskellFile> <module> <expression>\n"
|
||||||
++ "\t ghc-mod info <HaskellFile> <module> <expression>\n"
|
++ "\t ghc-mod info <HaskellFile> <module> <expression>\n"
|
||||||
++ "\t ghc-mod [-h opt] lint <HaskellFile>\n"
|
++ "\t ghc-mod lint [-h opt] <HaskellFile>\n"
|
||||||
++ "\t ghc-mod boot\n"
|
++ "\t ghc-mod boot\n"
|
||||||
++ "\t ghc-mod help\n"
|
++ "\t ghc-mod help\n"
|
||||||
|
|
||||||
@ -39,6 +39,7 @@ defaultOptions :: Options
|
|||||||
defaultOptions = Options {
|
defaultOptions = Options {
|
||||||
convert = toPlain
|
convert = toPlain
|
||||||
, hlintOpts = []
|
, hlintOpts = []
|
||||||
|
, operators = False
|
||||||
}
|
}
|
||||||
|
|
||||||
argspec :: [OptDescr (Options -> Options)]
|
argspec :: [OptDescr (Options -> Options)]
|
||||||
@ -48,6 +49,9 @@ argspec = [ Option "l" ["tolisp"]
|
|||||||
, Option "h" ["hlintOpt"]
|
, Option "h" ["hlintOpt"]
|
||||||
(ReqArg (\h opts -> opts { hlintOpts = h : hlintOpts opts }) "hlintOpt")
|
(ReqArg (\h opts -> opts { hlintOpts = h : hlintOpts opts }) "hlintOpt")
|
||||||
"hint to be ignored"
|
"hint to be ignored"
|
||||||
|
, Option "o" ["operators"]
|
||||||
|
(NoArg (\opts -> opts { operators = True }))
|
||||||
|
"print operators, too"
|
||||||
]
|
]
|
||||||
|
|
||||||
parseArgs :: [OptDescr (Options -> Options)] -> [String] -> (Options, [String])
|
parseArgs :: [OptDescr (Options -> Options)] -> [String] -> (Options, [String])
|
||||||
|
1
Types.hs
1
Types.hs
@ -11,6 +11,7 @@ import GHC.Paths (libdir)
|
|||||||
data Options = Options {
|
data Options = Options {
|
||||||
convert :: [String] -> String
|
convert :: [String] -> String
|
||||||
, hlintOpts :: [String]
|
, hlintOpts :: [String]
|
||||||
|
, operators :: Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
withGHC :: (MonadPlus m) => Ghc (m a) -> IO (m a)
|
withGHC :: (MonadPlus m) => Ghc (m a) -> IO (m a)
|
||||||
|
Loading…
Reference in New Issue
Block a user