module GhcPlugins(
module Plugins,
module RdrName, module OccName, module Name, module Var, module Id, module IdInfo,
module CoreMonad, module CoreSyn, module Literal, module DataCon,
module CoreUtils, module MkCore, module CoreFVs, module CoreSubst,
module Rules, module Annotations,
module DynFlags, module Packages,
module Module, module Type, module TyCon, module Coercion,
module TysWiredIn, module HscTypes, module BasicTypes,
module VarSet, module VarEnv, module NameSet, module NameEnv,
module UniqSet, module UniqFM, module FiniteMap,
module Util, module GHC.Serialized, module SrcLoc, module Outputable,
module UniqSupply, module Unique, module FastString,
thNameToGhcName
) where
import Plugins
import RdrName
import OccName hiding ( varName )
import Name hiding ( varName )
import Var
import Id hiding ( lazySetIdInfo, setIdExported, setIdNotExported )
import IdInfo
import CoreMonad
import CoreSyn
import Literal
import DataCon
import CoreUtils
import MkCore
import CoreFVs
import CoreSubst hiding( substTyVarBndr, substCoVarBndr, extendCvSubst )
import Rules
import Annotations
import DynFlags
import Packages
import Module
import Type hiding
( substTy, extendTvSubst, extendTvSubstList, isInScope )
import Coercion hiding
( substCo )
import TyCon
import TysWiredIn
import HscTypes
import BasicTypes hiding ( Version )
import VarSet
import VarEnv
import NameSet
import NameEnv
import UniqSet
import UniqFM
import FiniteMap
import Util
import GHC.Serialized
import SrcLoc
import Outputable
import UniqSupply
import Unique ( Unique, Uniquable(..) )
import FastString
import Data.Maybe
import IfaceEnv ( lookupOrigIO )
import GhcPrelude
import MonadUtils ( mapMaybeM )
import Convert ( thRdrNameGuesses )
import TcEnv ( lookupGlobal )
import qualified Language.Haskell.TH as TH
instance MonadThings CoreM where
lookupThing name = do { hsc_env <- getHscEnv
; liftIO $ lookupGlobal hsc_env name }
thNameToGhcName :: TH.Name -> CoreM (Maybe Name)
thNameToGhcName th_name
= do { names <- mapMaybeM lookup (thRdrNameGuesses th_name)
; return (listToMaybe names) }
where
lookup rdr_name
| Just n <- isExact_maybe rdr_name
= return $ if isExternalName n then Just n else Nothing
| Just (rdr_mod, rdr_occ) <- isOrig_maybe rdr_name
= do { hsc_env <- getHscEnv
; Just <$> liftIO (lookupOrigIO hsc_env rdr_mod rdr_occ) }
| otherwise = return Nothing