+
+pprTypeAndContents :: GhcMonad m => [Id] -> m SDoc
+pprTypeAndContents ids = do
+ dflags <- GHC.getSessionDynFlags
+ let pefas = dopt Opt_PrintExplicitForalls dflags
+ pcontents = dopt Opt_PrintBindContents dflags
+ if pcontents
+ then do
+ let depthBound = 100
+ terms <- mapM (GHC.obtainTermFromId depthBound False) ids
+ docs_terms <- mapM showTerm terms
+ return $ vcat $ zipWith (\ty cts -> ty <+> equals <+> cts)
+ (map (pprTyThing pefas . AnId) ids)
+ docs_terms
+ else return $ vcat $ map (pprTyThing pefas . AnId) ids
+
+--------------------------------------------------------------
+-- Utils
+
+traceOptIf :: GhcMonad m => DynFlag -> SDoc -> m ()
+traceOptIf flag doc = do
+ dflags <- GHC.getSessionDynFlags
+ when (dopt flag dflags) $ liftIO $ printForUser stderr alwaysQualify doc