5 lines
1.8 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>IStdlib__PhysEqual (infer.IStdlib__PhysEqual)</title><link rel="stylesheet" href="../../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 1.5.1"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div class="content"><header><nav><a href="../index.html">Up</a> <a href="../index.html">infer</a> &#x00BB; IStdlib__PhysEqual</nav><h1>Module <code>IStdlib__PhysEqual</code></h1></header><aside><p>Helpers function to enforce physical equality.</p><p>Let suppose <code>construct/deconstruct</code> is a 1-level-allocation OCaml construction/deconstruction, such as variant type, tuple or record construction. Instead of writing</p><pre><code class="ml">let a = deconstruct a0 in
let b = deconstruct b0 in
let res = f a b in
if phys_equal res a then a0 else if phys_equal res b then b0 else construct res</code></pre><p>Simply write</p><pre><code class="ml">PhysEqual.optim2 ~res:(construct (f a b)) a0 b0 </code></pre></aside><dl><dt class="spec value" id="val-optim1"><a href="#val-optim1" class="anchor"></a><code><span class="keyword">val</span> optim1 : <span>res:<span class="type-var">'a</span></span> <span>&#45;&gt;</span> <span class="type-var">'a</span> <span>&#45;&gt;</span> <span class="type-var">'a</span></code></dt><dt class="spec value" id="val-optim2"><a href="#val-optim2" class="anchor"></a><code><span class="keyword">val</span> optim2 : <span>res:<span class="type-var">'a</span></span> <span>&#45;&gt;</span> <span class="type-var">'a</span> <span>&#45;&gt;</span> <span class="type-var">'a</span> <span>&#45;&gt;</span> <span class="type-var">'a</span></code></dt></dl></div></body></html>