0.3 Release (#115)
* Add total ConvertText alternative to Conv * Explain ConvertText's meaning * Rename convertText to toS for compatibility * 0.3.0 Refactor (#111) * Begin work on 0.3 refactor * Remove old docs folder * Fix dodgy exports * 4.8 constraint for null and length * Guards for Semigroup export for base<4.9 * Fix Data.Bits exports * Guards for typeable exports * Remove unused pragmas * Update hlint.yaml * Use liftM because of pre-AMP quirkk * Data.Char exports * Rework Exception exports * Fix bounds * Adding Monad.Fail shim * Fix displayException export * Explicit GHC.Prim import for ancient ghc * Explicit raise# for base-4.7 * Flush legacy testing infrastructure * Update git location * Update README * Add Partial module * Add concurrency exports * Explicit GHC.Float exports * Bounds for threadWaitReadSTM, threadWaitWriteSTM, forkOSWithUnmask * Fix for weird undocumented underflowError weirdness * forkOSWithUnask for base>4.8 * Fix GHC.Real exports pre base-4.7 * Fix withMVarMasked for base-4.7 * Update nix derivation * Update derivation * Update derivation * Explicit functor exports * <$ export * Overwrite binary * Fix some missing exports * Update Changelog * Minor export fixes base<4.9 * Explicit exports * Export handler * Generate export lists for multiple versions (#114) * Generate export lists for #112 * Make export lists format OccName uniformly * Make compile on ancient GHC * Use Foldable.concat * Hacks to make ghc-7.6 API happy * liftIO shim * Fix sortOn warning * Update ChangeLog * Update base bounds * Export conventions * Update Haddocks * Document GHC magic
This commit is contained in:
+59
@@ -0,0 +1,59 @@
|
||||
{-# LANGUAGE CPP #-}
|
||||
module Main
|
||||
( main,
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Applicative ((<$>))
|
||||
import Control.Monad.Trans
|
||||
import Data.Foldable (concat)
|
||||
import qualified Data.List as List
|
||||
import Data.Maybe
|
||||
import Data.Ord (comparing)
|
||||
import DynFlags
|
||||
import GHC
|
||||
import GhcMonad
|
||||
import GHC.Paths
|
||||
import Outputable
|
||||
import System.FilePath.Posix
|
||||
import Prelude hiding (concat, mod)
|
||||
|
||||
autoModule :: FilePath -> IO ()
|
||||
autoModule mod = runGhc (Just GHC.Paths.libdir) $ do
|
||||
dflags <- GHC.getSessionDynFlags
|
||||
#if (__GLASGOW_HASKELL__ > 706)
|
||||
_ <- setSessionDynFlags ( dflags `gopt_set` Opt_GhciSandbox )
|
||||
#else
|
||||
_ <- setSessionDynFlags ( dflags `dopt_set` Opt_GhciSandbox )
|
||||
#endif
|
||||
target <- guessTarget ("src" </> addExtension mod ".hs") Nothing
|
||||
setTargets [target]
|
||||
_ <- load LoadAllTargets
|
||||
modSum <- getModSummary $ mkModuleName mod
|
||||
p <- GHC.parseModule modSum
|
||||
t <- typecheckModule p
|
||||
let modInfo = tm_checked_module_info t
|
||||
let exports = modInfoExports modInfo
|
||||
exportThings <- sequence <$> mapM lookupName exports
|
||||
let sortedThings = List.sortBy (comparing getOccName) (concat exportThings)
|
||||
GhcMonad.liftIO (mapM_ (showThing dflags) sortedThings)
|
||||
|
||||
showNamed :: NamedThing a => DynFlags -> a -> IO ()
|
||||
showNamed df a = do
|
||||
let nm = showSDoc df (ppr (getOccName a))
|
||||
let mod = showSDoc df (ppr (nameModule (getName a)))
|
||||
putStrLn (nm ++ " from " ++ mod)
|
||||
|
||||
showThing :: DynFlags -> TyThing -> IO ()
|
||||
showThing df (AnId a) = showNamed df a
|
||||
#if (__GLASGOW_HASKELL__ > 706)
|
||||
showThing df (AConLike a) = showNamed df a
|
||||
#endif
|
||||
showThing df (ATyCon a) = showNamed df a
|
||||
showThing _ _ = error "Should never happen."
|
||||
|
||||
--showGhc :: (Outputable a) => a -> String
|
||||
--showGhc = showPpr unsafeGlobalDynFlags
|
||||
|
||||
main :: IO ()
|
||||
main = autoModule "Protolude"
|
||||
Reference in New Issue
Block a user