{-# OPTIONS_GHC -fno-warn-duplicate-exports -fno-warn-orphans #-}
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 -> CoreM TyThing
lookupThing name :: Name
name = do { HscEnv
hsc_env <- CoreM HscEnv
getHscEnv
; IO TyThing -> CoreM TyThing
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TyThing -> CoreM TyThing) -> IO TyThing -> CoreM TyThing
forall a b. (a -> b) -> a -> b
$ HscEnv -> Name -> IO TyThing
lookupGlobal HscEnv
hsc_env Name
name }
thNameToGhcName :: TH.Name -> CoreM (Maybe Name)
thNameToGhcName :: Name -> CoreM (Maybe Name)
thNameToGhcName th_name :: Name
th_name
= do { [Name]
names <- (RdrName -> CoreM (Maybe Name)) -> [RdrName] -> CoreM [Name]
forall (m :: * -> *) a b.
Applicative m =>
(a -> m (Maybe b)) -> [a] -> m [b]
mapMaybeM RdrName -> CoreM (Maybe Name)
lookup (Name -> [RdrName]
thRdrNameGuesses Name
th_name)
; Maybe Name -> CoreM (Maybe Name)
forall (m :: * -> *) a. Monad m => a -> m a
return ([Name] -> Maybe Name
forall a. [a] -> Maybe a
listToMaybe [Name]
names) }
where
lookup :: RdrName -> CoreM (Maybe Name)
lookup rdr_name :: RdrName
rdr_name
| Just n :: Name
n <- RdrName -> Maybe Name
isExact_maybe RdrName
rdr_name
= Maybe Name -> CoreM (Maybe Name)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Name -> CoreM (Maybe Name))
-> Maybe Name -> CoreM (Maybe Name)
forall a b. (a -> b) -> a -> b
$ if Name -> Bool
isExternalName Name
n then Name -> Maybe Name
forall a. a -> Maybe a
Just Name
n else Maybe Name
forall a. Maybe a
Nothing
| Just (rdr_mod :: Module
rdr_mod, rdr_occ :: OccName
rdr_occ) <- RdrName -> Maybe (Module, OccName)
isOrig_maybe RdrName
rdr_name
= do { HscEnv
hsc_env <- CoreM HscEnv
getHscEnv
; Name -> Maybe Name
forall a. a -> Maybe a
Just (Name -> Maybe Name) -> CoreM Name -> CoreM (Maybe Name)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO Name -> CoreM Name
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (HscEnv -> Module -> OccName -> IO Name
lookupOrigIO HscEnv
hsc_env Module
rdr_mod OccName
rdr_occ) }
| Bool
otherwise = Maybe Name -> CoreM (Maybe Name)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Name
forall a. Maybe a
Nothing