[commit: ghc] master: Fixed plugin example to work (3de019c)
git at git.haskell.org
git at git.haskell.org
Sat Dec 8 04:28:55 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/3de019cb320a36b68039c1e2731e15cb72b33c0f/ghc
>---------------------------------------------------------------
commit 3de019cb320a36b68039c1e2731e15cb72b33c0f
Author: abc <hoge at example.com>
Date: Sun Nov 25 14:16:00 2018 +0900
Fixed plugin example to work
>---------------------------------------------------------------
3de019cb320a36b68039c1e2731e15cb72b33c0f
docs/users_guide/extending_ghc.rst | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/docs/users_guide/extending_ghc.rst b/docs/users_guide/extending_ghc.rst
index ef07f61..20d9674 100644
--- a/docs/users_guide/extending_ghc.rst
+++ b/docs/users_guide/extending_ghc.rst
@@ -739,12 +739,13 @@ displayed.
import HsDoc
plugin :: Plugin
- plugin = defaultPlugin { parsedResultAction = parsedPlugin
- , renamedResultAction = Just renamedAction
- , typeCheckResultAction = typecheckPlugin
- , spliceRunAction = metaPlugin
- , interfaceLoadAction = interfaceLoadPlugin
- }
+ plugin = defaultPlugin
+ { parsedResultAction = parsedPlugin
+ , renamedResultAction = renamedAction
+ , typeCheckResultAction = typecheckPlugin
+ , spliceRunAction = metaPlugin
+ , interfaceLoadAction = interfaceLoadPlugin
+ }
parsedPlugin :: [CommandLineOption] -> ModSummary -> HsParsedModule -> Hsc HsParsedModule
parsedPlugin _ _ pm
@@ -752,13 +753,11 @@ displayed.
liftIO $ putStrLn $ "parsePlugin: \n" ++ (showSDoc dflags $ ppr $ hpm_module pm)
return pm
- renamedAction :: [CommandLineOption] -> ModSummary
- -> ( HsGroup GhcRn, [LImportDecl GhcRn]
- , Maybe [(LIE GhcRn, Avails)], Maybe LHsDocString )
- -> TcM ()
- renamedAction _ _ ( gr, _, _, _ )
- = do dflags <- getDynFlags
- liftIO $ putStrLn $ "typeCheckPlugin (rn): " ++ (showSDoc dflags $ ppr gr)
+ renamedAction :: [CommandLineOption] -> TcGblEnv -> HsGroup GhcRn -> TcM (TcGblEnv, HsGroup GhcRn)
+ renamedAction _ tc gr = do
+ dflags <- getDynFlags
+ liftIO $ putStrLn $ "typeCheckPlugin (rn): " ++ (showSDoc dflags $ ppr gr)
+ return (tc, gr)
typecheckPlugin :: [CommandLineOption] -> ModSummary -> TcGblEnv -> TcM TcGblEnv
typecheckPlugin _ _ tc
@@ -783,12 +782,13 @@ When you compile a simple module that contains Template Haskell splice
::
+ {-# OPTIONS_GHC -fplugin SourcePlugin #-}
{-# LANGUAGE TemplateHaskell #-}
module A where
a = ()
- $(return [])
+$(return [])
with the compiler flags ``-fplugin SourcePlugin`` it will give the following
output:
More information about the ghc-commits
mailing list