2010-03-11 10:03:17 +00:00
|
|
|
module Browse (browseModule) where
|
|
|
|
|
2010-04-28 06:51:30 +00:00
|
|
|
import Control.Applicative
|
2010-03-11 10:03:17 +00:00
|
|
|
import Data.Char
|
|
|
|
import Data.List
|
2010-04-28 06:51:30 +00:00
|
|
|
import GHC
|
|
|
|
import Name
|
2010-04-30 09:36:31 +00:00
|
|
|
import Types
|
2010-03-11 10:03:17 +00:00
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
2010-03-11 13:39:07 +00:00
|
|
|
browseModule :: Options -> String -> IO String
|
2010-04-28 06:51:30 +00:00
|
|
|
browseModule opt mdlName = convert opt . validate <$> browse mdlName
|
2010-03-11 10:03:17 +00:00
|
|
|
where
|
2010-04-28 06:51:30 +00:00
|
|
|
validate = sort . filter (isAlpha.head)
|
2010-03-11 10:03:17 +00:00
|
|
|
|
2010-04-28 06:51:30 +00:00
|
|
|
browse :: String -> IO [String]
|
2010-04-30 09:36:31 +00:00
|
|
|
browse mdlName = withGHC $ do
|
|
|
|
initSession0
|
2010-04-30 07:27:10 +00:00
|
|
|
maybeNamesToStrings <$> lookupModuleInfo
|
2010-04-27 01:28:00 +00:00
|
|
|
where
|
2010-04-28 08:02:59 +00:00
|
|
|
lookupModuleInfo = findModule (mkModuleName mdlName) Nothing >>= getModuleInfo
|
2010-04-28 06:51:30 +00:00
|
|
|
maybeNamesToStrings = maybe [] (map getOccString . modInfoExports)
|