ocaml-trace/ppxlib/Ppxlib/Extension/index.html
2025-12-12 13:56:43 +00:00

30 lines
11 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Extension (ppxlib.Ppxlib.Extension)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 3.1.0"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> <a href="../../../index.html">Index</a> &#x00BB; <a href="../../index.html">ppxlib</a> &#x00BB; <a href="../index.html">Ppxlib</a> &#x00BB; Extension</nav><header class="odoc-preamble"><h1>Module <code><span>Ppxlib.Extension</span></code></h1><p>Declare extenders to rewrite extension nodes.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-equality"><a href="#type-equality" class="anchor"></a><code><span><span class="keyword">type</span> <span>(_, _) equality</span></span><span> = </span></code><ol><li id="type-equality.Eq" class="def variant constructor anchored"><a href="#type-equality.Eq" class="anchor"></a><code><span>| </span><span><span class="constructor">Eq</span> : <span><span>(<span class="type-var">'a</span>, <span class="type-var">'a</span>)</span> <a href="#type-equality">equality</a></span></span></code></li><li id="type-equality.Ne" class="def variant constructor anchored"><a href="#type-equality.Ne" class="anchor"></a><code><span>| </span><span><span class="constructor">Ne</span> : <span><span>(<span class="type-var">_</span>, <span class="type-var">_</span>)</span> <a href="#type-equality">equality</a></span></span></code></li></ol></div></div><div class="odoc-spec"><div class="spec module anchored" id="module-Context"><a href="#module-Context" class="anchor"></a><code><span><span class="keyword">module</span> <a href="Context/index.html">Context</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-t"><a href="#type-t" class="anchor"></a><code><span><span class="keyword">type</span> t</span></code></div><div class="spec-doc"><p>Type of declared extensions.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-declare"><a href="#val-declare" class="anchor"></a><code><span><span class="keyword">val</span> declare :
<span>string <span class="arrow">&#45;&gt;</span></span>
<span><span><span class="type-var">'context</span> <a href="Context/index.html#type-t">Context.t</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><span><span>(<a href="../../Astlib/Ast_502/Parsetree/index.html#type-payload">Astlib.Ast_502.Parsetree.payload</a>, <span class="type-var">'a</span>, <span class="type-var">'context</span>)</span> <a href="../Ast_pattern/index.html#type-t">Ast_pattern.t</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><span>(<span><span class="label">loc</span>:<a href="../Location/index.html#type-t">Location.t</a> <span class="arrow">&#45;&gt;</span></span> <span><span class="label">path</span>:string <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span>)</span> <span class="arrow">&#45;&gt;</span></span>
<a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>declare name context pattern expander</code> declares the extension names <code>name</code> for <code>context</code>.</p><p><code>expander</code> is responsible for producing the code to replace the extension in the AST. It receives as argument:</p><ul><li><code>loc</code>: the location of the enclosing node. For instance for expression it is the <code>pexp_loc</code> field</li><li><code>path</code>: the current module path</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-declare_with_path_arg"><a href="#val-declare_with_path_arg" class="anchor"></a><code><span><span class="keyword">val</span> declare_with_path_arg :
<span>string <span class="arrow">&#45;&gt;</span></span>
<span><span><span class="type-var">'context</span> <a href="Context/index.html#type-t">Context.t</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><span><span>(<a href="../../Astlib/Ast_502/Parsetree/index.html#type-payload">Astlib.Ast_502.Parsetree.payload</a>, <span class="type-var">'a</span>, <span class="type-var">'context</span>)</span> <a href="../Ast_pattern/index.html#type-t">Ast_pattern.t</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><span>(<span><span class="label">loc</span>:<a href="../Location/index.html#type-t">Location.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="label">path</span>:string <span class="arrow">&#45;&gt;</span></span>
<span><span class="label">arg</span>:<span><span><a href="../Longident/index.html#type-t">Longident.t</a> <a href="../../Astlib/Ast_502/Asttypes/index.html#type-loc">Ppxlib_ast.Asttypes.loc</a></span> option</span> <span class="arrow">&#45;&gt;</span></span>
<span class="type-var">'a</span>)</span> <span class="arrow">&#45;&gt;</span></span>
<a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Same as <code>declare</code> except that the extension name takes an additional path argument. The path is the part of the name that start with a capitalized component. For instance in the following, the extension <code>&quot;map&quot;</code> would receive the path argument <code>Foo.Bar</code>:</p><pre class="language-ocaml"><code> let%map.Foo.Bar x = 1 in
...</code></pre></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-declare_inline"><a href="#val-declare_inline" class="anchor"></a><code><span><span class="keyword">val</span> declare_inline :
<span>string <span class="arrow">&#45;&gt;</span></span>
<span><span><span class="type-var">'context</span> <a href="Context/index.html#type-t">Context.t</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><span><span>(<a href="../../Astlib/Ast_502/Parsetree/index.html#type-payload">Astlib.Ast_502.Parsetree.payload</a>, <span class="type-var">'a</span>, <span><span class="type-var">'context</span> list</span>)</span> <a href="../Ast_pattern/index.html#type-t">Ast_pattern.t</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><span>(<span><span class="label">loc</span>:<a href="../Location/index.html#type-t">Location.t</a> <span class="arrow">&#45;&gt;</span></span> <span><span class="label">path</span>:string <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span>)</span> <span class="arrow">&#45;&gt;</span></span>
<a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Inline the result of the expansion into its parent. Only works for these contexts:</p><ul><li><code>class_field</code></li><li><code>class_type_field</code></li><li><code>signature_item</code></li><li><code>structure_item</code></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-declare_inline_with_path_arg"><a href="#val-declare_inline_with_path_arg" class="anchor"></a><code><span><span class="keyword">val</span> declare_inline_with_path_arg :
<span>string <span class="arrow">&#45;&gt;</span></span>
<span><span><span class="type-var">'context</span> <a href="Context/index.html#type-t">Context.t</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><span><span>(<a href="../../Astlib/Ast_502/Parsetree/index.html#type-payload">Astlib.Ast_502.Parsetree.payload</a>, <span class="type-var">'a</span>, <span><span class="type-var">'context</span> list</span>)</span> <a href="../Ast_pattern/index.html#type-t">Ast_pattern.t</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><span>(<span><span class="label">loc</span>:<a href="../Location/index.html#type-t">Location.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="label">path</span>:string <span class="arrow">&#45;&gt;</span></span>
<span><span class="label">arg</span>:<span><span><a href="../Longident/index.html#type-t">Longident.t</a> <a href="../../Astlib/Ast_502/Asttypes/index.html#type-loc">Ppxlib_ast.Asttypes.loc</a></span> option</span> <span class="arrow">&#45;&gt;</span></span>
<span class="type-var">'a</span>)</span> <span class="arrow">&#45;&gt;</span></span>
<a href="#type-t">t</a></span></code></div></div><div class="odoc-spec"><div class="spec module anchored" id="module-For_context"><a href="#module-For_context" class="anchor"></a><code><span><span class="keyword">module</span> <a href="For_context/index.html">For_context</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div><div class="spec-doc"><p>This module is used to implement <a href="../Context_free/class-map_top_down/index.html"><code>Context_free.map_top_down</code></a></p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-filter_by_context"><a href="#val-filter_by_context" class="anchor"></a><code><span><span class="keyword">val</span> filter_by_context : <span><span><span class="type-var">'a</span> <a href="Context/index.html#type-t">Context.t</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span><a href="#type-t">t</a> list</span> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> <a href="For_context/index.html#type-t">For_context.t</a></span> list</span></span></code></div><div class="spec-doc"><p>Given a context and a list of extension expander, returns all the ones that are for this context.</p></div></div><div class="odoc-spec"><div class="spec module anchored" id="module-Expert"><a href="#module-Expert" class="anchor"></a><code><span><span class="keyword">module</span> <a href="Expert/index.html">Expert</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div><div class="spec-doc"><p>This module allows to declare extensions that do not produce a value of the context type. This is typically useful for extensions point that depends on more things from the context than the path and location.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-check_unused"><a href="#val-check_unused" class="anchor"></a><code><span><span class="keyword">val</span> check_unused : <a href="../Ast_traverse/class-iter/index.html">Ast_traverse.iter</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-collect_unhandled_extension_errors"><a href="#val-collect_unhandled_extension_errors" class="anchor"></a><code><span><span class="keyword">val</span> collect_unhandled_extension_errors :
<span><span><a href="../Location/Error/index.html#type-t">Location.Error.t</a> list</span> <a href="../Ast_traverse/class-fold/index.html">Ast_traverse.fold</a></span></span></code></div></div><div class="odoc-spec"><div class="spec module anchored" id="module-V2"><a href="#module-V2" class="anchor"></a><code><span><span class="keyword">module</span> <a href="V2/index.html">V2</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div></div><div class="odoc-spec"><div class="spec module anchored" id="module-V3"><a href="#module-V3" class="anchor"></a><code><span><span class="keyword">module</span> <a href="V3/index.html">V3</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div></div></div></body></html>