diff options
author | Facundo DomÃnguez <facundo.dominguez@tweag.io> | 2017-09-21 18:04:56 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-09-21 20:13:04 -0400 |
commit | 175586908963a6d438cf3c28922a38191f4eaa66 (patch) | |
tree | c481ea2193d5b15aba917e201869ba0772510dec /libraries/ghci | |
parent | a9d417dab21e0b677f13c2ba99244162a8fffe3e (diff) | |
download | haskell-175586908963a6d438cf3c28922a38191f4eaa66.tar.gz |
Implement TH addCorePlugin.
This allows template-haskell code to add plugins to the compilation
pipeline. Otherwise, the user would have to pass -fplugin=... to ghc.
For now, plugin modules in the current package can't be used. This is
because when TH runs, it is too late to let GHC know that the plugin
modules needed to be compiled first.
Test Plan: ./validate
Reviewers: simonpj, bgamari, austin, goldfire
Reviewed By: bgamari
Subscribers: angerman, rwbarton, mboes, thomie
GHC Trac Issues: #13608
Differential Revision: https://phabricator.haskell.org/D3821
Diffstat (limited to 'libraries/ghci')
-rw-r--r-- | libraries/ghci/GHCi/Message.hs | 5 | ||||
-rw-r--r-- | libraries/ghci/GHCi/TH.hs | 1 |
2 files changed, 5 insertions, 1 deletions
diff --git a/libraries/ghci/GHCi/Message.hs b/libraries/ghci/GHCi/Message.hs index fe63d641a4..de91c5bd40 100644 --- a/libraries/ghci/GHCi/Message.hs +++ b/libraries/ghci/GHCi/Message.hs @@ -240,6 +240,7 @@ data THMessage a where AddDependentFile :: FilePath -> THMessage (THResult ()) AddModFinalizer :: RemoteRef (TH.Q ()) -> THMessage (THResult ()) + AddCorePlugin :: String -> THMessage (THResult ()) AddTopDecls :: [TH.Dec] -> THMessage (THResult ()) AddForeignFile :: ForeignSrcLang -> String -> THMessage (THResult ()) IsExtEnabled :: Extension -> THMessage (THResult Bool) @@ -278,7 +279,8 @@ getTHMessage = do 15 -> THMsg <$> EndRecover <$> get 16 -> return (THMsg RunTHDone) 17 -> THMsg <$> AddModFinalizer <$> get - _ -> THMsg <$> (AddForeignFile <$> get <*> get) + 18 -> THMsg <$> (AddForeignFile <$> get <*> get) + _ -> THMsg <$> AddCorePlugin <$> get putTHMessage :: THMessage a -> Put putTHMessage m = case m of @@ -301,6 +303,7 @@ putTHMessage m = case m of RunTHDone -> putWord8 16 AddModFinalizer a -> putWord8 17 >> put a AddForeignFile lang a -> putWord8 18 >> put lang >> put a + AddCorePlugin a -> putWord8 19 >> put a data EvalOpts = EvalOpts diff --git a/libraries/ghci/GHCi/TH.hs b/libraries/ghci/GHCi/TH.hs index 09fbca7e32..905e003c1a 100644 --- a/libraries/ghci/GHCi/TH.hs +++ b/libraries/ghci/GHCi/TH.hs @@ -199,6 +199,7 @@ instance TH.Quasi GHCiQ where qAddForeignFile str lang = ghcCmd (AddForeignFile str lang) qAddModFinalizer fin = GHCiQ (\s -> mkRemoteRef fin >>= return . (, s)) >>= ghcCmd . AddModFinalizer + qAddCorePlugin str = ghcCmd (AddCorePlugin str) qGetQ = GHCiQ $ \s -> let lookup :: forall a. Typeable a => Map TypeRep Dynamic -> Maybe a lookup m = fromDynamic =<< M.lookup (typeOf (undefined::a)) m |