hint
hint copied to clipboard
`typeOf` triggers deprecation warnings
If the user can't use these identifiers nor obtain their types, maybe we shouldn't list them in getModuleExports?
-- |
-- >>> :{
-- do contents <- browse "Data.Map"
-- for_ contents $ \(identifier, tp) -> do
-- putStrLn $ identifier ++ " :: " ++ tp
-- :}
-- *** Exception: WontCompile [GhcError {errMsg = "<interactive>:1:1: error: Data.Map.fold is gone. Use foldr."}]
browse :: Hint.ModuleName -> IO [(String, String)]
browse moduleName = runInterpreter $ do
Hint.setImports ["Prelude", "Data.Typeable", moduleName]
exports <- Hint.getModuleExports moduleName
execWriterT $ do
for_ exports $ \case
Hint.Fun identifier -> do
tp <- lift $ Hint.typeOf identifier
tell [(identifier, tp)]
_ -> pure () -- skip datatypes and typeclasses