Skip to content

Commit

Permalink
Add P.S. to Impureim Sandwich
Browse files Browse the repository at this point in the history
  • Loading branch information
ploeh committed Jan 18, 2025
1 parent 5eb3c33 commit 42c44d1
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion _posts/2020-03-02-impureim-sandwich.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h3 id="b1755f32e36d4a07b336d1b8fdc1b227">
Functional architecture <a href="#b1755f32e36d4a07b336d1b8fdc1b227" title="permalink">#</a>
</h3>
<p>
In <a href="/2018/11/19/functional-architecture-a-definition">a functional architecture</a> <a href="https://en.wikipedia.org/wiki/Pure_function">pure functions</a> can't call impure actions. On the other hand, as <a href="https://en.wikipedia.org/wiki/Simon_Peyton_Jones">Simon Peyton Jones</a> observed in a lecture, <em>observing the result of pure computation is a side-effect</em>. In practical terms, <em>executing</em> a pure function is also impure, because it happens non-deterministically. Thus, even for a piece of software written in a functional style, the entry point must be impure.
In <a href="/2018/11/19/functional-architecture-a-definition">a functional architecture</a>, <a href="https://en.wikipedia.org/wiki/Pure_function">pure functions</a> can't call impure actions. On the other hand, as <a href="https://en.wikipedia.org/wiki/Simon_Peyton_Jones">Simon Peyton Jones</a> observed in a lecture, <em>observing the result of pure computation is a side-effect</em>. In practical terms, <em>executing</em> a pure function is also impure, because it happens non-deterministically. Thus, even for a piece of software written in a functional style, the entry point must be impure.
</p>
<p>
While pure functions can't call impure actions, there's no rule to prevent the obverse. Impure actions <em>can</em> call pure functions.
Expand Down Expand Up @@ -130,6 +130,23 @@ <h3 id="df74d63c013646aa9355b95e74fc3edc">
<p>
I suggest that we call such an <em>impure/pure/impure</em> interaction an <em>impureim sandwich</em>, and that we pronounce it an <em>impurium sandwich</em>.
</p>
<ins datetime="2025-01-18">
<p>
<strong>P.S. 2025-01-18:</strong>
</p>
<p>
See also the following, subsequently-published articles that expand on the notion:
</p>
<ul>
<li><a href="/2022/02/14/a-conditional-sandwich-example">A conditional sandwich example</a></li>
<li><a href="/2023/10/09/whats-a-sandwich">What's a sandwich?</a></li>
<li><a href="/2024/12/16/a-restaurant-sandwich">A restaurant sandwich</a></li>
<li><a href="/2025/01/13/recawr-sandwich">Recawr Sandwich</a></li>
</ul>
<p>
In them you can find more examples, and answers to some frequently asked questions.
</p>
</ins>
</div>

<div id="comments">
Expand Down

0 comments on commit 42c44d1

Please sign in to comment.