Skip to content

Commit

Permalink
update page
Browse files Browse the repository at this point in the history
  • Loading branch information
nadia-polikarpova committed Nov 1, 2023
1 parent 34d5a3a commit 5385eec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions docs/lectures/04-hof.html
Original file line number Diff line number Diff line change
Expand Up @@ -549,14 +549,14 @@ <h2 id="the-case-of-the-missing-parameter">The Case of the Missing Parameter</h2
<br></p>
<h2 id="the-case-of-the-missing-parameter-1">The Case of the Missing Parameter</h2>
<p>Recall lambda calculus:</p>
<p>The expressions <code class="sourceCode haskell">f</code> and <code class="sourceCode haskell">\x <span class="ot">-&gt;</span> f x</code> are in some sense “equivalent”</p>
<p>The expressions <code class="sourceCode haskell"><span class="dt">F</span></code> and <code class="sourceCode haskell">\x <span class="ot">-&gt;</span> <span class="dt">F</span> x</code> are in some sense “equivalent”</p>
<ul>
<li>as long as <code class="sourceCode haskell">x <span class="fu">not</span> <span class="kw">in</span> <span class="dt">FV</span>(f)</code></li>
<li>as long as <code class="sourceCode haskell">x <span class="fu">not</span> <span class="kw">in</span> <span class="dt">FV</span>(<span class="dt">F</span>)</code></li>
</ul>
<p>because they behave the same way when applied to any argument <code class="sourceCode haskell">e</code>:</p>
<div class="sourceCode" id="cb20"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a>(\x <span class="ot">-&gt;</span> f x) e</span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a><span class="ot">=</span>b<span class="op">&gt;</span> f e</span></code></pre></div>
<p>Transforming <code class="sourceCode haskell">\x <span class="ot">-&gt;</span> f x</code> into <code class="sourceCode haskell">f</code> is called <strong>eta contraction</strong></p>
<p>because they behave the same way when applied to any argument <code class="sourceCode haskell"><span class="dt">E</span></code>:</p>
<div class="sourceCode" id="cb20"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a>(\x <span class="ot">-&gt;</span> <span class="dt">F</span> x) <span class="dt">E</span></span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a><span class="ot">=</span>b<span class="op">&gt;</span> <span class="dt">F</span> <span class="dt">E</span></span></code></pre></div>
<p>Transforming <code class="sourceCode haskell">\x <span class="ot">-&gt;</span> <span class="dt">F</span> x</code> into <code class="sourceCode haskell"><span class="dt">F</span></code> is called <strong>eta contraction</strong></p>
<ul>
<li>and the reverse is called <strong>eta expansion</strong></li>
</ul>
Expand All @@ -577,12 +577,12 @@ <h2 id="the-case-of-the-missing-parameter-1">The Case of the Missing Parameter</
<br>
<br></p>
<p>More generally, whenever you want to define a function:</p>
<div class="sourceCode" id="cb23"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a>f x y z <span class="ot">=</span> e x y z</span></code></pre></div>
<div class="sourceCode" id="cb23"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a>f x y z <span class="ot">=</span> <span class="dt">E</span> x y z</span></code></pre></div>
<p>you can save some typing, and <em>omit</em> the parameters:</p>
<ul>
<li>as long as <code class="sourceCode haskell">x</code>, <code class="sourceCode haskell">y</code>, and <code class="sourceCode haskell">z</code> are not free in <code class="sourceCode haskell">e</code></li>
<li>as long as <code class="sourceCode haskell">x</code>, <code class="sourceCode haskell">y</code>, and <code class="sourceCode haskell">z</code> are not free in <code class="sourceCode haskell"><span class="dt">E</span></code></li>
</ul>
<div class="sourceCode" id="cb24"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a>f <span class="ot">=</span> e</span></code></pre></div>
<div class="sourceCode" id="cb24"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a>f <span class="ot">=</span> <span class="dt">E</span></span></code></pre></div>
<p><br>
<br>
<br>
Expand Down
18 changes: 9 additions & 9 deletions lectures/04-hof.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,18 +431,18 @@ Where did `xs` and `x` go???

Recall lambda calculus:

The expressions `f` and `\x -> f x` are in some sense "equivalent"
The expressions `F` and `\x -> F x` are in some sense "equivalent"

- as long as `x not in FV(f)`
- as long as `x not in FV(F)`

because they behave the same way when applied to any argument `e`:
because they behave the same way when applied to any argument `E`:

```haskell
(\x -> f x) e
=b> f e
(\x -> F x) E
=b> F E
```

Transforming `\x -> f x` into `f` is called **eta contraction**
Transforming `\x -> F x` into `F` is called **eta contraction**

- and the reverse is called **eta expansion**

Expand Down Expand Up @@ -475,15 +475,15 @@ map toUpper
More generally, whenever you want to define a function:

```haskell
f x y z = e x y z
f x y z = E x y z
```

you can save some typing, and *omit* the parameters:

- as long as `x`, `y`, and `z` are not free in `e`
- as long as `x`, `y`, and `z` are not free in `E`

```haskell
f = e
f = E
```


Expand Down

0 comments on commit 5385eec

Please sign in to comment.