diff options
author | abc <hoge@example.com> | 2018-11-25 14:16:00 +0900 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-12-07 22:52:25 -0500 |
commit | 3de019cb320a36b68039c1e2731e15cb72b33c0f (patch) | |
tree | 2ce24adc68e4f62a087c9cc17a5d86210832314c /docs | |
parent | eb7ba36b8350d07ad89da2afebea4b17deb711ca (diff) | |
download | haskell-3de019cb320a36b68039c1e2731e15cb72b33c0f.tar.gz |
Fixed plugin example to work
Diffstat (limited to 'docs')
-rw-r--r-- | docs/users_guide/extending_ghc.rst | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/docs/users_guide/extending_ghc.rst b/docs/users_guide/extending_ghc.rst index ef07f61f2d..20d9674843 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: |