hint icon indicating copy to clipboard operation
hint copied to clipboard

`typeOf` triggers deprecation warnings

Open gelisam opened this issue 5 years ago • 0 comments

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

gelisam avatar Feb 17 '20 19:02 gelisam