summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorPhil de Joux <philderbeast@gmail.com>2022-03-20 11:25:47 -0400
committerMatthew Pickering <matthewtpickering@gmail.com>2022-04-01 11:04:56 +0100
commitdd7c7c998aea402bd5d8ae7ef7854a3bb60bcf2b (patch)
treeeead6719eb0c2a958b17fbb2e0cd36f78a7b1379 /docs
parent418e6fab732b9aaa0a00c5e235f445fb547ae196 (diff)
downloadhaskell-dd7c7c998aea402bd5d8ae7ef7854a3bb60bcf2b.tar.gz
Add tests and docs on plugin args and order.
Diffstat (limited to 'docs')
-rw-r--r--docs/users_guide/extending_ghc.rst31
1 files changed, 30 insertions, 1 deletions
diff --git a/docs/users_guide/extending_ghc.rst b/docs/users_guide/extending_ghc.rst
index b2b555c005..a265a8323e 100644
--- a/docs/users_guide/extending_ghc.rst
+++ b/docs/users_guide/extending_ghc.rst
@@ -216,7 +216,36 @@ option. The list of enabled plugins can be reset with the
:category: plugins
Give arguments to a plugin module; module must be specified with
- :ghc-flag:`-fplugin=⟨module⟩`.
+ :ghc-flag:`-fplugin=⟨module⟩`. The order of plugin pragmas matter but the
+ order of arg pragmas does not. The same set of arguments go to all plugins
+ from the same module.
+
+ ::
+
+ -- Two Echo plugins will both get args A and B.
+ {-# OPTIONS -fplugin Echo -fplugin-opt Echo:A #-}
+ {-# OPTIONS -fplugin Echo -fplugin-opt Echo:B #-}
+
+ -- While order of the plugins matters, arg order does not.
+ {-# OPTIONS -fplugin-opt Echo2:B #-}
+
+ {-# OPTIONS -fplugin Echo1 #-}
+ {-# OPTIONS -fplugin-opt Echo1:A #-}
+
+ {-# OPTIONS -fplugin Echo2 #-}
+
+ If you want to use the same plugin with different arguments then rexport the
+ same plugin from different lightweight modules.
+
+ ::
+
+ -- Echo1 and Echo2 as lightweight modules re-exporting Echo.plugin.
+ module Echo1 (plugin) where import Echo (plugin)
+ module Echo2 (plugin) where import Echo (plugin)
+
+ -- Echo1 gets arg A while Echo2 gets arg B.
+ {-# OPTIONS -fplugin Echo1 -fplugin-opt Echo1:A #-}
+ {-# OPTIONS -fplugin Echo2 -fplugin-opt Echo2:B #-}
.. ghc-flag:: -fplugin-trustworthy
:shortdesc: Trust the used plugins and no longer mark the compiled module