summaryrefslogtreecommitdiff
path: root/public/post
diff options
context:
space:
mode:
Diffstat (limited to 'public/post')
-rw-r--r--public/post/2017-08-16-tapl/index.html288
-rw-r--r--public/post/2017-08-17-untyped-arithmetic-expressions/index.html226
-rw-r--r--public/post/2017-08-22-thinkpad-e470/index.html300
-rw-r--r--public/post/2017-08-24-untyped-lambda-calculus/index.html233
-rw-r--r--public/post/2018-09-11-shapeless/index.html229
-rw-r--r--public/post/fairstream/index.html263
-rw-r--r--public/post/index.html351
-rw-r--r--public/post/index.xml9
-rw-r--r--public/post/simple-fair-and-terminating-backtracking-monad-transformer/index.html258
9 files changed, 1822 insertions, 335 deletions
diff --git a/public/post/2017-08-16-tapl/index.html b/public/post/2017-08-16-tapl/index.html
index d0ce0d0..bf71d20 100644
--- a/public/post/2017-08-16-tapl/index.html
+++ b/public/post/2017-08-16-tapl/index.html
@@ -1,146 +1,224 @@
<!DOCTYPE html>
<html lang="en">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
-
- <title>Types and Programming Languages | </title>
- <meta name="viewport" content="width=device-width,minimum-scale=1">
- <meta name="description" content="February 2016, as a birthday present to myself I bought a copy of Types and Programming Languages. At the time the only thing I did with it was to take a photo of it, sharing it on Twitter and congratulating myself. To be fair, I did try reading it, but it was so intimidating that I gave up very early in the book. One and a half years later I’m going to give it another go because a few things have changed.">
- <meta name="generator" content="Hugo 0.155.0">
-
-
-
- <meta name="robots" content="index, follow">
-
-
+<head>
+
+ <title>Types and Programming Languages :: </title>
+
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="description" content="February 2016, as a birthday present to myself I bought a copy of Types and Programming Languages. At the time the only thing I did with it was to take a photo of it, sharing it on Twitter and congratulating myself. To be fair, I did try reading it, but it was so intimidating that I gave up very early in the book. One and a half years later I’m going to give it another go because a few things have changed.
+" />
+<meta name="keywords" content="" />
-
-<link rel="stylesheet" href="/ananke/css/main.min.efe4d852f731d5d1fbb87718387202a97aafd768cdcdaed0662bbe6982e91824.css" >
+ <meta name="robots" content="noodp" />
+<link rel="canonical" href="https://blog.gluegadget.com/post/2017-08-16-tapl/" />
-
-
-
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/buttons.min.86f6b4c106b6c6eb690ae5203d36b442c1f66f718ff4e8164fa86cf6c61ad641.css">
-
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/code.min.d529ea4b2fb8d34328d7d31afc5466d5f7bc2f0bc9abdd98b69385335d7baee4.css">
-
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/fonts.min.5bb7ed13e1d00d8ff39ea84af26737007eb5051b157b86fc24487c94f3dc8bbe.css">
-
- <link rel="canonical" href="https://blog.gluegadget.com/post/2017-08-16-tapl/">
-
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/footer.min.eb8dfc2c6a7eafa36cd3ba92d63e69e849e2200e0002a228d137f236b09ecd75.css">
-
-
- <meta property="og:url" content="https://blog.gluegadget.com/post/2017-08-16-tapl/">
- <meta property="og:title" content="Types and Programming Languages">
- <meta property="og:description" content="February 2016, as a birthday present to myself I bought a copy of Types and Programming Languages. At the time the only thing I did with it was to take a photo of it, sharing it on Twitter and congratulating myself. To be fair, I did try reading it, but it was so intimidating that I gave up very early in the book. One and a half years later I’m going to give it another go because a few things have changed.">
- <meta property="og:locale" content="en">
- <meta property="og:type" content="article">
- <meta property="article:section" content="post">
- <meta property="article:published_time" content="2017-08-16T00:00:00+00:00">
- <meta property="article:modified_time" content="2017-08-16T00:00:00+00:00">
- <meta property="article:tag" content="Tapl">
- <meta property="article:tag" content="Rust">
-
- <meta itemprop="name" content="Types and Programming Languages">
- <meta itemprop="description" content="February 2016, as a birthday present to myself I bought a copy of Types and Programming Languages. At the time the only thing I did with it was to take a photo of it, sharing it on Twitter and congratulating myself. To be fair, I did try reading it, but it was so intimidating that I gave up very early in the book. One and a half years later I’m going to give it another go because a few things have changed.">
- <meta itemprop="datePublished" content="2017-08-16T00:00:00+00:00">
- <meta itemprop="dateModified" content="2017-08-16T00:00:00+00:00">
- <meta itemprop="wordCount" content="318">
- <meta itemprop="keywords" content="Tapl,Rust">
- <meta name="twitter:card" content="summary">
- <meta name="twitter:title" content="Types and Programming Languages">
- <meta name="twitter:description" content="February 2016, as a birthday present to myself I bought a copy of Types and Programming Languages. At the time the only thing I did with it was to take a photo of it, sharing it on Twitter and congratulating myself. To be fair, I did try reading it, but it was so intimidating that I gave up very early in the book. One and a half years later I’m going to give it another go because a few things have changed.">
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/gist.min.a751e8b0abe1ba8bc53ced52a38b19d8950fe78ca29454ea8c2595cf26aad5c0.css">
-
-
-
-
- </head><body class="ma0 avenir bg-near-white production is-page is-page page-2017-08-16-tapl">
-
-
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/header.min.75c7eb0e2872d95ff48109c6647d0223a38db52e2561dd87966eb5fc7c6bdac6.css">
- <header>
- <div class="bg-black">
- <nav class="pv3 ph3 ph4-ns" role="navigation">
- <div class="flex-l center items-center justify-between">
- <a href="/" class="f3 fw2 hover-white white-90 dib no-underline">
-
-
-
- </a>
- <div class="flex-l items-center">
-
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/main.min.36833afd348409fc6c3d09d0897c5833d9d5bf1ff31f5e60ea3ee42ce2b1268c.css">
-
- <div class="ananke-socials"></div>
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/menu.min.3c17467ebeb3d38663dce68f71f519901124fa5cbb4519b2fb0667a21e9aca39.css">
- </div>
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/pagination.min.bbb986dbce00a5ce5aca0504b7925fc1c581992a4bf57f163e5d69cc1db7d836.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/post.min.e6dddd258e64c83e05cec0cd49c05216742d42fc8ecbfbe6b67083412b609bd3.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/syntax.min.a0773cce9310cb6d8ed23e50f005448facf29a53001b57e038828daa466b25c0.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/terminal.min.e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/terms.min.b81791663c3790e738e571cdbf802312390d30e4b1d8dc9d814a5b5454d0ac11.css">
+
+
+
+
+
+
+
+<link rel="shortcut icon" href="https://blog.gluegadget.com/favicon.png">
+<link rel="apple-touch-icon" href="https://blog.gluegadget.com/apple-touch-icon.png">
+
+
+<meta name="twitter:card" content="summary" />
+
+
+
+<meta property="og:locale" content="en" />
+<meta property="og:type" content="article" />
+<meta property="og:title" content="Types and Programming Languages">
+<meta property="og:description" content="February 2016, as a birthday present to myself I bought a copy of Types and Programming Languages. At the time the only thing I did with it was to take a photo of it, sharing it on Twitter and congratulating myself. To be fair, I did try reading it, but it was so intimidating that I gave up very early in the book. One and a half years later I’m going to give it another go because a few things have changed.
+" />
+<meta property="og:url" content="https://blog.gluegadget.com/post/2017-08-16-tapl/" />
+<meta property="og:site_name" content="" />
+
+ <meta property="og:image" content="https://blog.gluegadget.com/og-image.png">
+
+<meta property="og:image:width" content="1200">
+<meta property="og:image:height" content="627">
+
+
+ <meta property="article:published_time" content="2017-08-16 00:00:00 &#43;0000 UTC" />
+
+
+
+
+
+
+
+
+
+<script>
+window.MathJax = {
+ tex: {
+ inlineMath: [['$', '$'], ['\\(', '\\)']],
+ displayMath: [['$$', '$$'], ['\\[', '\\]']],
+ processEscapes: true,
+ processEnvironments: true
+ },
+ options: {
+ skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre']
+ }
+};
+</script>
+<script id="MathJax-script" async src="/mathjax/tex-mml-chtml.js"></script>
+
+
+</head>
+<body>
+
+
+<div class="container center">
+
+ <header class="header">
+ <div class="header__inner">
+ <div class="header__logo">
+ <a href="https://blog.gluegadget.com/">
+ <div class="logo">
+ Terminal
</div>
-</nav>
+</a>
</div>
- </header>
+
+
+ </div>
+
+</header>
+ <div class="content">
+
+<article class="post">
+ <h1 class="post-title">
+ <a href="https://blog.gluegadget.com/post/2017-08-16-tapl/">Types and Programming Languages</a>
+ </h1>
+ <div class="post-meta"><time class="post-date">2017-08-16</time></div>
- <main class="pb7" role="main">
-
-
- <article class="page-2017-08-16-tapl flex-l mw7 center ph3 flex-wrap justify-between">
- <header class="mt4 w-100">
- <aside class="instapaper_ignoref b helvetica tracked ttu">
-
- Posts
- </aside><div id="sharing" class="mt3 ananke-socials"></div>
-<h1 class="f1 athelas mt3 mb1">Types and Programming Languages</h1>
+ <span class="post-tags">
+ #<a href="https://blog.gluegadget.com/tags/tapl/">tapl</a>&nbsp;
+ #<a href="https://blog.gluegadget.com/tags/rust/">rust</a>&nbsp;
- <time class="f6 mv4 dib tracked" datetime="2017-08-16T00:00:00Z">August 16, 2017</time>
-
+ </span>
+
+
-
-
- </header>
- <div class="nested-copy-line-height lh-copy serif f4 nested-links mid-gray pr4-l w-100-l"><p>February 2016, as a birthday present to myself I bought a copy of <a href="https://www.cis.upenn.edu/~bcpierce/tapl/">Types and Programming Languages</a>. At the time the only thing I did with it was to take a photo of it, sharing it on Twitter and congratulating myself. To be fair, I did try reading it, but it was so intimidating that I gave up very early in the book. One and a half years later I’m going to give it another go because a few things have changed.</p>
+
+
+
+ <div class="post-content"><div>
+ <p>February 2016, as a birthday present to myself I bought a copy of <a href="https://www.cis.upenn.edu/~bcpierce/tapl/">Types and Programming Languages</a>. At the time the only thing I did with it was to take a photo of it, sharing it on Twitter and congratulating myself. To be fair, I did try reading it, but it was so intimidating that I gave up very early in the book. One and a half years later I’m going to give it another go because a few things have changed.</p>
<p>First of all, I should say that I&rsquo;ve no academic background in computer science—I&rsquo;ve studied Zoology. I easily get frightened by any text with more than a few lines of maths in it especially when it&rsquo;s heavy on symbols which I don&rsquo;t know, and Google doesn&rsquo;t help. I&rsquo;ve had many attempts at learning maths—watching YouTube videos, reading books—but I always gave up mostly due to lack of discipline in doing the exercises. A year ago I decided to do something about it and enrolled into DIT&rsquo;s <a href="http://www.dt249.ie/">B.Sc. in Information Systems and Information Technology</a>. I thought if I&rsquo;m paying a substantial amount of money for a class in a relatively well-established institute it might help. To my unwelcome surprise, the course isn&rsquo;t heavy on maths, but it was an immense help, discipline-wise, nonetheless.</p>
<p>The second thing was that due to some unforeseen circumstances, all of a sudden I found myself with plenty of free time and I didn&rsquo;t want to waste this once in a lifetime opportunity.</p>
<p>After deciding that I want to read the book and be rigorous in doing the exercises, I had to choose a programming language to do the exercises in, and I found it a good excuse to give Rust a try.</p>
<p>I also decided to publish my progress both as in <a href="https://github.com/amir/tapl.rs">code</a> as well as in a series of blog posts, as suggested by a wise man, <a href="http://iainhull.github.io/">Iain</a>. Hence this blog.</p>
-<ul class="pa0">
+
+ </div></div>
+
+
+
+<div class="pagination">
+ <div class="pagination__title">
+ <span class="pagination__title-h"></span>
+ <hr />
+ </div>
+ <div class="pagination__buttons">
+
+ <a href="https://blog.gluegadget.com/post/2017-08-22-thinkpad-e470/" class="button inline prev">
+ &lt; [<span class="button__text">ThinkPad E470</span>]
+ </a>
+
+
+
+ </div>
+</div>
+
+
- <li class="list di">
- <a href="/tags/tapl/" class="link f5 grow br-pill ba ph3 pv2 mb2 dib black sans-serif no-underline">Tapl</a>
- </li>
+
- <li class="list di">
- <a href="/tags/rust/" class="link f5 grow br-pill ba ph3 pv2 mb2 dib black sans-serif no-underline">Rust</a>
- </li>
+
+
-</ul>
+</article>
-
- </div></article>
-
- </main>
- <footer class="bg-black bottom-0 w-100 pa3" role="contentinfo">
- <div class="flex justify-between">
- <a class="f4 fw4 hover-white white-70 dn dib-ns pv2 ph3 no-underline" href="https://blog.gluegadget.com/" >
- &copy;
- </a>
- <div><div class="ananke-socials"></div>
-</div>
+ </div>
+
+
+ <footer class="footer">
+ <div class="footer__inner">
+
+ <div class="copyright">
+ <span>© 2026 Powered by <a href="https://gohugo.io">Hugo</a></span>
+
+ <span>:: <a href="https://github.com/panr/hugo-theme-terminal" target="_blank">Theme</a> made by <a href="https://github.com/panr" target="_blank">panr</a></span>
+ </div>
</div>
</footer>
- </body>
+
+
+
+
+
+<script type="text/javascript" src="/bundle.min.js"></script>
+
+
+
+
+
+
+</div>
+
+</body>
</html>
diff --git a/public/post/2017-08-17-untyped-arithmetic-expressions/index.html b/public/post/2017-08-17-untyped-arithmetic-expressions/index.html
new file mode 100644
index 0000000..5997c93
--- /dev/null
+++ b/public/post/2017-08-17-untyped-arithmetic-expressions/index.html
@@ -0,0 +1,226 @@
+<!DOCTYPE html>
+<html lang="en">
+<head><script src="/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=livereload" data-no-instant defer></script>
+
+ <title>Untyped Arithmetic Expressions :: </title>
+
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="description" content="Chapters 3 and 4 of the book develop the required tools for a small and trivial language of numbers and booleans. You can find the OCaml implementation of this language on book&rsquo;s website. And you can find my Rust implementation at arith.rs.
+" />
+<meta name="keywords" content="" />
+
+ <meta name="robots" content="noodp" />
+
+<link rel="canonical" href="http://localhost:1313/post/2017-08-17-untyped-arithmetic-expressions/" />
+
+
+
+
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/buttons.min.86f6b4c106b6c6eb690ae5203d36b442c1f66f718ff4e8164fa86cf6c61ad641.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/code.min.d529ea4b2fb8d34328d7d31afc5466d5f7bc2f0bc9abdd98b69385335d7baee4.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/fonts.min.5bb7ed13e1d00d8ff39ea84af26737007eb5051b157b86fc24487c94f3dc8bbe.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/footer.min.eb8dfc2c6a7eafa36cd3ba92d63e69e849e2200e0002a228d137f236b09ecd75.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/gist.min.a751e8b0abe1ba8bc53ced52a38b19d8950fe78ca29454ea8c2595cf26aad5c0.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/header.min.75c7eb0e2872d95ff48109c6647d0223a38db52e2561dd87966eb5fc7c6bdac6.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/main.min.36833afd348409fc6c3d09d0897c5833d9d5bf1ff31f5e60ea3ee42ce2b1268c.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/menu.min.3c17467ebeb3d38663dce68f71f519901124fa5cbb4519b2fb0667a21e9aca39.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/pagination.min.bbb986dbce00a5ce5aca0504b7925fc1c581992a4bf57f163e5d69cc1db7d836.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/post.min.e6dddd258e64c83e05cec0cd49c05216742d42fc8ecbfbe6b67083412b609bd3.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/syntax.min.a0773cce9310cb6d8ed23e50f005448facf29a53001b57e038828daa466b25c0.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/terminal.min.e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/terms.min.b81791663c3790e738e571cdbf802312390d30e4b1d8dc9d814a5b5454d0ac11.css">
+
+
+
+
+
+
+
+<link rel="shortcut icon" href="http://localhost:1313/favicon.png">
+<link rel="apple-touch-icon" href="http://localhost:1313/apple-touch-icon.png">
+
+
+<meta name="twitter:card" content="summary" />
+
+
+
+<meta property="og:locale" content="en" />
+<meta property="og:type" content="article" />
+<meta property="og:title" content="Untyped Arithmetic Expressions">
+<meta property="og:description" content="Chapters 3 and 4 of the book develop the required tools for a small and trivial language of numbers and booleans. You can find the OCaml implementation of this language on book&rsquo;s website. And you can find my Rust implementation at arith.rs.
+" />
+<meta property="og:url" content="http://localhost:1313/post/2017-08-17-untyped-arithmetic-expressions/" />
+<meta property="og:site_name" content="" />
+
+ <meta property="og:image" content="http://localhost:1313/og-image.png">
+
+<meta property="og:image:width" content="1200">
+<meta property="og:image:height" content="627">
+
+
+ <meta property="article:published_time" content="2017-08-17 00:00:00 &#43;0000 UTC" />
+
+
+
+
+
+
+
+
+
+<script>
+window.MathJax = {
+ tex: {
+ inlineMath: [['$', '$'], ['\\(', '\\)']],
+ displayMath: [['$$', '$$'], ['\\[', '\\]']],
+ processEscapes: true,
+ processEnvironments: true
+ },
+ options: {
+ skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre']
+ }
+};
+</script>
+<script id="MathJax-script" async src="/mathjax/tex-mml-chtml.js"></script>
+
+
+</head>
+<body>
+
+
+<div class="container center">
+
+ <header class="header">
+ <div class="header__inner">
+ <div class="header__logo">
+ <a href="http://localhost:1313/">
+ <div class="logo">
+ Terminal
+ </div>
+</a>
+
+ </div>
+
+
+ </div>
+
+</header>
+
+
+ <div class="content">
+
+<article class="post">
+ <h1 class="post-title">
+ <a href="http://localhost:1313/post/2017-08-17-untyped-arithmetic-expressions/">Untyped Arithmetic Expressions</a>
+ </h1>
+ <div class="post-meta"><time class="post-date">2017-08-17</time></div>
+
+
+ <span class="post-tags">
+
+ #<a href="http://localhost:1313/tags/tapl/">tapl</a>&nbsp;
+
+ #<a href="http://localhost:1313/tags/rust/">rust</a>&nbsp;
+
+ </span>
+
+
+
+
+
+
+ <div class="post-content"><div>
+ <p>Chapters 3 and 4 of the book develop the required tools for a small and trivial language of numbers and booleans. You can find the <a href="https://www.cis.upenn.edu/~bcpierce/tapl/checkers/arith.tar.gz">OCaml implementation</a> of this language on book&rsquo;s website. And you can find my Rust implementation at <a href="https://github.com/amir/tapl.rs/blob/master/src/tapl/arith.rs">arith.rs</a>.</p>
+
+ </div></div>
+
+
+
+<div class="pagination">
+ <div class="pagination__title">
+ <span class="pagination__title-h"></span>
+ <hr />
+ </div>
+ <div class="pagination__buttons">
+
+ <a href="http://localhost:1313/post/2017-08-22-thinkpad-e470/" class="button inline prev">
+ &lt; [<span class="button__text">ThinkPad E470</span>]
+ </a>
+
+
+ ::
+
+
+ <a href="http://localhost:1313/post/2017-08-16-tapl/" class="button inline next">
+ [<span class="button__text">Types and Programming Languages</span>] &gt;
+ </a>
+
+ </div>
+</div>
+
+
+
+
+
+
+
+
+</article>
+
+ </div>
+
+
+ <footer class="footer">
+ <div class="footer__inner">
+
+ <div class="copyright">
+ <span>© 2026 Powered by <a href="https://gohugo.io">Hugo</a></span>
+
+ <span>:: <a href="https://github.com/panr/hugo-theme-terminal" target="_blank">Theme</a> made by <a href="https://github.com/panr" target="_blank">panr</a></span>
+ </div>
+ </div>
+</footer>
+
+
+
+
+
+
+<script type="text/javascript" src="/bundle.min.js"></script>
+
+
+
+
+
+
+</div>
+
+</body>
+</html>
diff --git a/public/post/2017-08-22-thinkpad-e470/index.html b/public/post/2017-08-22-thinkpad-e470/index.html
index 3f0cc7d..666c98f 100644
--- a/public/post/2017-08-22-thinkpad-e470/index.html
+++ b/public/post/2017-08-22-thinkpad-e470/index.html
@@ -1,121 +1,165 @@
<!DOCTYPE html>
<html lang="en">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
-
- <title>ThinkPad E470 | </title>
- <meta name="viewport" content="width=device-width,minimum-scale=1">
- <meta name="description" content="Recently I&rsquo;ve been looking for a Linux-friendly, budget laptop. I like ThinkPads, and all of my laptops have been either T-series or X-series but this time I didn&rsquo;t want to spend that amount of money and was looking for cheaper alternatives.
-Browsing Lenovo website, I realised that a reasonably configured E470 would cost about €1000 which was about how much I was willing to pay. I configured it, so it has:">
- <meta name="generator" content="Hugo 0.155.0">
-
-
-
- <meta name="robots" content="index, follow">
-
-
+<head>
+
+ <title>ThinkPad E470 :: </title>
+
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="description" content="Recently I&rsquo;ve been looking for a Linux-friendly, budget laptop. I like ThinkPads, and all of my laptops have been either T-series or X-series but this time I didn&rsquo;t want to spend that amount of money and was looking for cheaper alternatives.
+Browsing Lenovo website, I realised that a reasonably configured E470 would cost about €1000 which was about how much I was willing to pay. I configured it, so it has:
+" />
+<meta name="keywords" content="" />
-
-<link rel="stylesheet" href="/ananke/css/main.min.efe4d852f731d5d1fbb87718387202a97aafd768cdcdaed0662bbe6982e91824.css" >
+ <meta name="robots" content="noodp" />
+<link rel="canonical" href="https://blog.gluegadget.com/post/2017-08-22-thinkpad-e470/" />
-
-
-
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/buttons.min.86f6b4c106b6c6eb690ae5203d36b442c1f66f718ff4e8164fa86cf6c61ad641.css">
-
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/code.min.d529ea4b2fb8d34328d7d31afc5466d5f7bc2f0bc9abdd98b69385335d7baee4.css">
-
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/fonts.min.5bb7ed13e1d00d8ff39ea84af26737007eb5051b157b86fc24487c94f3dc8bbe.css">
-
- <link rel="canonical" href="https://blog.gluegadget.com/post/2017-08-22-thinkpad-e470/">
-
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/footer.min.eb8dfc2c6a7eafa36cd3ba92d63e69e849e2200e0002a228d137f236b09ecd75.css">
-
-
- <meta property="og:url" content="https://blog.gluegadget.com/post/2017-08-22-thinkpad-e470/">
- <meta property="og:title" content="ThinkPad E470">
- <meta property="og:description" content="Recently I’ve been looking for a Linux-friendly, budget laptop. I like ThinkPads, and all of my laptops have been either T-series or X-series but this time I didn’t want to spend that amount of money and was looking for cheaper alternatives.
-Browsing Lenovo website, I realised that a reasonably configured E470 would cost about €1000 which was about how much I was willing to pay. I configured it, so it has:">
- <meta property="og:locale" content="en">
- <meta property="og:type" content="article">
- <meta property="article:section" content="post">
- <meta property="article:published_time" content="2017-08-22T00:00:00+00:00">
- <meta property="article:modified_time" content="2017-08-22T00:00:00+00:00">
- <meta property="article:tag" content="Thinkpad">
- <meta property="article:tag" content="E470">
-
- <meta itemprop="name" content="ThinkPad E470">
- <meta itemprop="description" content="Recently I’ve been looking for a Linux-friendly, budget laptop. I like ThinkPads, and all of my laptops have been either T-series or X-series but this time I didn’t want to spend that amount of money and was looking for cheaper alternatives.
-Browsing Lenovo website, I realised that a reasonably configured E470 would cost about €1000 which was about how much I was willing to pay. I configured it, so it has:">
- <meta itemprop="datePublished" content="2017-08-22T00:00:00+00:00">
- <meta itemprop="dateModified" content="2017-08-22T00:00:00+00:00">
- <meta itemprop="wordCount" content="296">
- <meta itemprop="keywords" content="Thinkpad,E470">
- <meta name="twitter:card" content="summary">
- <meta name="twitter:title" content="ThinkPad E470">
- <meta name="twitter:description" content="Recently I’ve been looking for a Linux-friendly, budget laptop. I like ThinkPads, and all of my laptops have been either T-series or X-series but this time I didn’t want to spend that amount of money and was looking for cheaper alternatives.
-Browsing Lenovo website, I realised that a reasonably configured E470 would cost about €1000 which was about how much I was willing to pay. I configured it, so it has:">
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/gist.min.a751e8b0abe1ba8bc53ced52a38b19d8950fe78ca29454ea8c2595cf26aad5c0.css">
-
-
-
-
- </head><body class="ma0 avenir bg-near-white production is-page is-page page-2017-08-22-thinkpad-e470">
-
-
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/header.min.75c7eb0e2872d95ff48109c6647d0223a38db52e2561dd87966eb5fc7c6bdac6.css">
- <header>
- <div class="bg-black">
- <nav class="pv3 ph3 ph4-ns" role="navigation">
- <div class="flex-l center items-center justify-between">
- <a href="/" class="f3 fw2 hover-white white-90 dib no-underline">
-
-
-
- </a>
- <div class="flex-l items-center">
-
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/main.min.36833afd348409fc6c3d09d0897c5833d9d5bf1ff31f5e60ea3ee42ce2b1268c.css">
-
- <div class="ananke-socials"></div>
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/menu.min.3c17467ebeb3d38663dce68f71f519901124fa5cbb4519b2fb0667a21e9aca39.css">
- </div>
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/pagination.min.bbb986dbce00a5ce5aca0504b7925fc1c581992a4bf57f163e5d69cc1db7d836.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/post.min.e6dddd258e64c83e05cec0cd49c05216742d42fc8ecbfbe6b67083412b609bd3.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/syntax.min.a0773cce9310cb6d8ed23e50f005448facf29a53001b57e038828daa466b25c0.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/terminal.min.e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/terms.min.b81791663c3790e738e571cdbf802312390d30e4b1d8dc9d814a5b5454d0ac11.css">
+
+
+
+
+
+
+
+<link rel="shortcut icon" href="https://blog.gluegadget.com/favicon.png">
+<link rel="apple-touch-icon" href="https://blog.gluegadget.com/apple-touch-icon.png">
+
+
+<meta name="twitter:card" content="summary" />
+
+
+
+<meta property="og:locale" content="en" />
+<meta property="og:type" content="article" />
+<meta property="og:title" content="ThinkPad E470">
+<meta property="og:description" content="Recently I&rsquo;ve been looking for a Linux-friendly, budget laptop. I like ThinkPads, and all of my laptops have been either T-series or X-series but this time I didn&rsquo;t want to spend that amount of money and was looking for cheaper alternatives.
+Browsing Lenovo website, I realised that a reasonably configured E470 would cost about €1000 which was about how much I was willing to pay. I configured it, so it has:
+" />
+<meta property="og:url" content="https://blog.gluegadget.com/post/2017-08-22-thinkpad-e470/" />
+<meta property="og:site_name" content="" />
+
+ <meta property="og:image" content="https://blog.gluegadget.com/og-image.png">
+
+<meta property="og:image:width" content="1200">
+<meta property="og:image:height" content="627">
+
+
+ <meta property="article:published_time" content="2017-08-22 00:00:00 &#43;0000 UTC" />
+
+
+
+
+
+
+
+
+
+<script>
+window.MathJax = {
+ tex: {
+ inlineMath: [['$', '$'], ['\\(', '\\)']],
+ displayMath: [['$$', '$$'], ['\\[', '\\]']],
+ processEscapes: true,
+ processEnvironments: true
+ },
+ options: {
+ skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre']
+ }
+};
+</script>
+<script id="MathJax-script" async src="/mathjax/tex-mml-chtml.js"></script>
+
+
+</head>
+<body>
+
+
+<div class="container center">
+
+ <header class="header">
+ <div class="header__inner">
+ <div class="header__logo">
+ <a href="https://blog.gluegadget.com/">
+ <div class="logo">
+ Terminal
</div>
-</nav>
+</a>
</div>
- </header>
+
+
+ </div>
+
+</header>
+ <div class="content">
+
+<article class="post">
+ <h1 class="post-title">
+ <a href="https://blog.gluegadget.com/post/2017-08-22-thinkpad-e470/">ThinkPad E470</a>
+ </h1>
+ <div class="post-meta"><time class="post-date">2017-08-22</time></div>
- <main class="pb7" role="main">
-
-
- <article class="page-2017-08-22-thinkpad-e470 flex-l mw7 center ph3 flex-wrap justify-between">
- <header class="mt4 w-100">
- <aside class="instapaper_ignoref b helvetica tracked ttu">
-
- Posts
- </aside><div id="sharing" class="mt3 ananke-socials"></div>
-<h1 class="f1 athelas mt3 mb1">ThinkPad E470</h1>
+ <span class="post-tags">
+ #<a href="https://blog.gluegadget.com/tags/thinkpad/">thinkpad</a>&nbsp;
+ #<a href="https://blog.gluegadget.com/tags/e470/">e470</a>&nbsp;
- <time class="f6 mv4 dib tracked" datetime="2017-08-22T00:00:00Z">August 22, 2017</time>
-
+ </span>
+
+
-
-
- </header>
- <div class="nested-copy-line-height lh-copy serif f4 nested-links mid-gray pr4-l w-100-l"><p>Recently I&rsquo;ve been looking for a Linux-friendly, budget laptop. I like ThinkPads, and all of my laptops have been either T-series or X-series but this time I didn&rsquo;t want to spend that amount of money and was looking for cheaper alternatives.</p>
+
+
+
+ <div class="post-content"><div>
+ <p>Recently I&rsquo;ve been looking for a Linux-friendly, budget laptop. I like ThinkPads, and all of my laptops have been either T-series or X-series but this time I didn&rsquo;t want to spend that amount of money and was looking for cheaper alternatives.</p>
<p>Browsing Lenovo website, I realised that a reasonably configured <a href="http://www3.lenovo.com/ie/en/laptops/thinkpad/edge-series/E470/p/22TP2TEE470">E470</a> would cost about €1000 which was about how much I was willing to pay. I configured it, so it has:</p>
<ul>
<li>Intel® Core™ i7-7500U</li>
@@ -143,31 +187,69 @@ Browsing Lenovo website, I realised that a reasonably configured E470 would cost
<ul>
<li>It&rsquo;s weighty, ugly, bulky, and the design is unimaginative.</li>
</ul>
-<ul class="pa0">
+
+ </div></div>
+
- <li class="list di">
- <a href="/tags/thinkpad/" class="link f5 grow br-pill ba ph3 pv2 mb2 dib black sans-serif no-underline">Thinkpad</a>
- </li>
+
+<div class="pagination">
+ <div class="pagination__title">
+ <span class="pagination__title-h"></span>
+ <hr />
+ </div>
+ <div class="pagination__buttons">
+
+ <a href="https://blog.gluegadget.com/post/fairstream/" class="button inline prev">
+ &lt; [<span class="button__text">Fairstream</span>]
+ </a>
+
+
+ ::
+
+
+ <a href="https://blog.gluegadget.com/post/2017-08-16-tapl/" class="button inline next">
+ [<span class="button__text">Types and Programming Languages</span>] &gt;
+ </a>
+
+ </div>
+</div>
+
+
- <li class="list di">
- <a href="/tags/e470/" class="link f5 grow br-pill ba ph3 pv2 mb2 dib black sans-serif no-underline">E470</a>
- </li>
+
-</ul>
+
+
+
+</article>
-
- </div></article>
-
- </main>
- <footer class="bg-black bottom-0 w-100 pa3" role="contentinfo">
- <div class="flex justify-between">
- <a class="f4 fw4 hover-white white-70 dn dib-ns pv2 ph3 no-underline" href="https://blog.gluegadget.com/" >
- &copy;
- </a>
- <div><div class="ananke-socials"></div>
-</div>
+ </div>
+
+
+ <footer class="footer">
+ <div class="footer__inner">
+
+ <div class="copyright">
+ <span>© 2026 Powered by <a href="https://gohugo.io">Hugo</a></span>
+
+ <span>:: <a href="https://github.com/panr/hugo-theme-terminal" target="_blank">Theme</a> made by <a href="https://github.com/panr" target="_blank">panr</a></span>
+ </div>
</div>
</footer>
- </body>
+
+
+
+
+
+<script type="text/javascript" src="/bundle.min.js"></script>
+
+
+
+
+
+
+</div>
+
+</body>
</html>
diff --git a/public/post/2017-08-24-untyped-lambda-calculus/index.html b/public/post/2017-08-24-untyped-lambda-calculus/index.html
new file mode 100644
index 0000000..b3556e7
--- /dev/null
+++ b/public/post/2017-08-24-untyped-lambda-calculus/index.html
@@ -0,0 +1,233 @@
+<!DOCTYPE html>
+<html lang="en">
+<head><script src="/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=livereload" data-no-instant defer></script>
+
+ <title>Untyped Lambda Calculus :: </title>
+
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="description" content="As I mentioned in an [earlier post]({% post_url 2017-08-16-tapl %}), I&rsquo;ve been working through Types and Programming Languages in Rust. Chapters 5 to 7 of TAPL discuss untyped lambda calculus through an implementation of a simple expression-based language. Chapter 5 lays the foundations; chapter 6 focuses more on one of the concepts introduced in chapter 5; de Bruijn index and chapter 7 explores an ML implementation of the said language, but only how to evaluate the terms, and not how to parse them. The accompanying OCaml implementation&rsquo;s parser is generated automatically from a Yacc grammar.
+" />
+<meta name="keywords" content="" />
+
+ <meta name="robots" content="noodp" />
+
+<link rel="canonical" href="http://localhost:1313/post/2017-08-24-untyped-lambda-calculus/" />
+
+
+
+
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/buttons.min.86f6b4c106b6c6eb690ae5203d36b442c1f66f718ff4e8164fa86cf6c61ad641.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/code.min.d529ea4b2fb8d34328d7d31afc5466d5f7bc2f0bc9abdd98b69385335d7baee4.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/fonts.min.5bb7ed13e1d00d8ff39ea84af26737007eb5051b157b86fc24487c94f3dc8bbe.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/footer.min.eb8dfc2c6a7eafa36cd3ba92d63e69e849e2200e0002a228d137f236b09ecd75.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/gist.min.a751e8b0abe1ba8bc53ced52a38b19d8950fe78ca29454ea8c2595cf26aad5c0.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/header.min.75c7eb0e2872d95ff48109c6647d0223a38db52e2561dd87966eb5fc7c6bdac6.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/main.min.36833afd348409fc6c3d09d0897c5833d9d5bf1ff31f5e60ea3ee42ce2b1268c.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/menu.min.3c17467ebeb3d38663dce68f71f519901124fa5cbb4519b2fb0667a21e9aca39.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/pagination.min.bbb986dbce00a5ce5aca0504b7925fc1c581992a4bf57f163e5d69cc1db7d836.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/post.min.e6dddd258e64c83e05cec0cd49c05216742d42fc8ecbfbe6b67083412b609bd3.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/syntax.min.a0773cce9310cb6d8ed23e50f005448facf29a53001b57e038828daa466b25c0.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/terminal.min.e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/terms.min.b81791663c3790e738e571cdbf802312390d30e4b1d8dc9d814a5b5454d0ac11.css">
+
+
+
+
+
+
+
+<link rel="shortcut icon" href="http://localhost:1313/favicon.png">
+<link rel="apple-touch-icon" href="http://localhost:1313/apple-touch-icon.png">
+
+
+<meta name="twitter:card" content="summary" />
+
+
+
+<meta property="og:locale" content="en" />
+<meta property="og:type" content="article" />
+<meta property="og:title" content="Untyped Lambda Calculus">
+<meta property="og:description" content="As I mentioned in an [earlier post]({% post_url 2017-08-16-tapl %}), I&rsquo;ve been working through Types and Programming Languages in Rust. Chapters 5 to 7 of TAPL discuss untyped lambda calculus through an implementation of a simple expression-based language. Chapter 5 lays the foundations; chapter 6 focuses more on one of the concepts introduced in chapter 5; de Bruijn index and chapter 7 explores an ML implementation of the said language, but only how to evaluate the terms, and not how to parse them. The accompanying OCaml implementation&rsquo;s parser is generated automatically from a Yacc grammar.
+" />
+<meta property="og:url" content="http://localhost:1313/post/2017-08-24-untyped-lambda-calculus/" />
+<meta property="og:site_name" content="" />
+
+ <meta property="og:image" content="http://localhost:1313/og-image.png">
+
+<meta property="og:image:width" content="1200">
+<meta property="og:image:height" content="627">
+
+
+ <meta property="article:published_time" content="2017-08-24 00:00:00 &#43;0000 UTC" />
+
+
+
+
+
+
+
+
+
+<script>
+window.MathJax = {
+ tex: {
+ inlineMath: [['$', '$'], ['\\(', '\\)']],
+ displayMath: [['$$', '$$'], ['\\[', '\\]']],
+ processEscapes: true,
+ processEnvironments: true
+ },
+ options: {
+ skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre']
+ }
+};
+</script>
+<script id="MathJax-script" async src="/mathjax/tex-mml-chtml.js"></script>
+
+
+</head>
+<body>
+
+
+<div class="container center">
+
+ <header class="header">
+ <div class="header__inner">
+ <div class="header__logo">
+ <a href="http://localhost:1313/">
+ <div class="logo">
+ Terminal
+ </div>
+</a>
+
+ </div>
+
+
+ </div>
+
+</header>
+
+
+ <div class="content">
+
+<article class="post">
+ <h1 class="post-title">
+ <a href="http://localhost:1313/post/2017-08-24-untyped-lambda-calculus/">Untyped Lambda Calculus</a>
+ </h1>
+ <div class="post-meta"><time class="post-date">2017-08-24</time></div>
+
+
+ <span class="post-tags">
+
+ #<a href="http://localhost:1313/tags/tapl/">tapl</a>&nbsp;
+
+ #<a href="http://localhost:1313/tags/rust/">rust</a>&nbsp;
+
+ </span>
+
+
+
+
+
+
+ <div class="post-content"><div>
+ <p>As I mentioned in an [earlier post]({% post_url 2017-08-16-tapl %}), I&rsquo;ve been working through <a href="https://www.cis.upenn.edu/~bcpierce/tapl/">Types and Programming Languages</a> in Rust. Chapters 5 to 7 of TAPL discuss untyped lambda calculus through an implementation of a simple expression-based language. Chapter 5 lays the foundations; chapter 6 focuses more on one of the concepts introduced in chapter 5; <a href="https://en.wikipedia.org/wiki/De_Bruijn_index">de Bruijn index</a> and chapter 7 explores an ML implementation of the said language, but only how to evaluate the terms, and not how to parse them. The accompanying OCaml <a href="https://www.cis.upenn.edu/~bcpierce/tapl/checkers/">implementation</a>&rsquo;s parser is generated automatically from a Yacc grammar.</p>
+<p>I&rsquo;ve had good experiences writting parsers in Haskell using <a href="https://hackage.haskell.org/package/parsec">parsec</a> and <a href="https://hackage.haskell.org/package/attoparsec">attoparsec</a> before, so I started looking for parser-combinators in Rust. There seem to be three capable options:</p>
+<ul>
+<li><a href="https://github.com/Marwes/combine">combine</a></li>
+<li><a href="https://github.com/m4rw3r/chomp">chomp</a></li>
+<li><a href="https://github.com/Geal/nom">nom</a></li>
+</ul>
+<p>Combine even has the <a href="https://github.com/Marwes/combine-language">combine-language</a> extension which is very similar to Parsec&rsquo;s <a href="http://hackage.haskell.org/package/parsec/docs/Text-Parsec-Token.html">Text.Parsec.Token</a> which would&rsquo;ve simplified the task of parsing lexical elements but I couldn&rsquo;t add it as a dependency to my project—due to compile errors which I&rsquo;m sure has been because of my ignorance and lack of familiarity with Rust and Cargo. At the end I ended up choosing using layman&rsquo;s metrics, number of GitHub stars and nom won by a huge margin.</p>
+
+ </div></div>
+
+
+
+<div class="pagination">
+ <div class="pagination__title">
+ <span class="pagination__title-h"></span>
+ <hr />
+ </div>
+ <div class="pagination__buttons">
+
+ <a href="http://localhost:1313/post/2018-09-11-shapeless/" class="button inline prev">
+ &lt; [<span class="button__text">Shapeless</span>]
+ </a>
+
+
+ ::
+
+
+ <a href="http://localhost:1313/post/2017-08-22-thinkpad-e470/" class="button inline next">
+ [<span class="button__text">ThinkPad E470</span>] &gt;
+ </a>
+
+ </div>
+</div>
+
+
+
+
+
+
+
+
+</article>
+
+ </div>
+
+
+ <footer class="footer">
+ <div class="footer__inner">
+
+ <div class="copyright">
+ <span>© 2026 Powered by <a href="https://gohugo.io">Hugo</a></span>
+
+ <span>:: <a href="https://github.com/panr/hugo-theme-terminal" target="_blank">Theme</a> made by <a href="https://github.com/panr" target="_blank">panr</a></span>
+ </div>
+ </div>
+</footer>
+
+
+
+
+
+
+<script type="text/javascript" src="/bundle.min.js"></script>
+
+
+
+
+
+
+</div>
+
+</body>
+</html>
diff --git a/public/post/2018-09-11-shapeless/index.html b/public/post/2018-09-11-shapeless/index.html
new file mode 100644
index 0000000..e54c9a9
--- /dev/null
+++ b/public/post/2018-09-11-shapeless/index.html
@@ -0,0 +1,229 @@
+<!DOCTYPE html>
+<html lang="en">
+<head><script src="/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=livereload" data-no-instant defer></script>
+
+ <title>Shapeless :: </title>
+
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="description" content="Shapeless
+import shapeless._ import shapeless.ops.hlist.{LiftAll, Mapper, Mapped} import shapeless.UnaryTCConstraint._ " />
+<meta name="keywords" content="" />
+
+ <meta name="robots" content="noodp" />
+
+<link rel="canonical" href="http://localhost:1313/post/2018-09-11-shapeless/" />
+
+
+
+
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/buttons.min.86f6b4c106b6c6eb690ae5203d36b442c1f66f718ff4e8164fa86cf6c61ad641.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/code.min.d529ea4b2fb8d34328d7d31afc5466d5f7bc2f0bc9abdd98b69385335d7baee4.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/fonts.min.5bb7ed13e1d00d8ff39ea84af26737007eb5051b157b86fc24487c94f3dc8bbe.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/footer.min.eb8dfc2c6a7eafa36cd3ba92d63e69e849e2200e0002a228d137f236b09ecd75.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/gist.min.a751e8b0abe1ba8bc53ced52a38b19d8950fe78ca29454ea8c2595cf26aad5c0.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/header.min.75c7eb0e2872d95ff48109c6647d0223a38db52e2561dd87966eb5fc7c6bdac6.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/main.min.36833afd348409fc6c3d09d0897c5833d9d5bf1ff31f5e60ea3ee42ce2b1268c.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/menu.min.3c17467ebeb3d38663dce68f71f519901124fa5cbb4519b2fb0667a21e9aca39.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/pagination.min.bbb986dbce00a5ce5aca0504b7925fc1c581992a4bf57f163e5d69cc1db7d836.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/post.min.e6dddd258e64c83e05cec0cd49c05216742d42fc8ecbfbe6b67083412b609bd3.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/syntax.min.a0773cce9310cb6d8ed23e50f005448facf29a53001b57e038828daa466b25c0.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/terminal.min.e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/terms.min.b81791663c3790e738e571cdbf802312390d30e4b1d8dc9d814a5b5454d0ac11.css">
+
+
+
+
+
+
+
+<link rel="shortcut icon" href="http://localhost:1313/favicon.png">
+<link rel="apple-touch-icon" href="http://localhost:1313/apple-touch-icon.png">
+
+
+<meta name="twitter:card" content="summary" />
+
+
+
+<meta property="og:locale" content="en" />
+<meta property="og:type" content="article" />
+<meta property="og:title" content="Shapeless">
+<meta property="og:description" content="Shapeless
+import shapeless._ import shapeless.ops.hlist.{LiftAll, Mapper, Mapped} import shapeless.UnaryTCConstraint._ " />
+<meta property="og:url" content="http://localhost:1313/post/2018-09-11-shapeless/" />
+<meta property="og:site_name" content="" />
+
+ <meta property="og:image" content="http://localhost:1313/og-image.png">
+
+<meta property="og:image:width" content="1200">
+<meta property="og:image:height" content="627">
+
+
+ <meta property="article:published_time" content="2018-09-11 00:00:00 &#43;0000 UTC" />
+
+
+
+
+
+
+
+
+
+<script>
+window.MathJax = {
+ tex: {
+ inlineMath: [['$', '$'], ['\\(', '\\)']],
+ displayMath: [['$$', '$$'], ['\\[', '\\]']],
+ processEscapes: true,
+ processEnvironments: true
+ },
+ options: {
+ skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre']
+ }
+};
+</script>
+<script id="MathJax-script" async src="/mathjax/tex-mml-chtml.js"></script>
+
+
+</head>
+<body>
+
+
+<div class="container center">
+
+ <header class="header">
+ <div class="header__inner">
+ <div class="header__logo">
+ <a href="http://localhost:1313/">
+ <div class="logo">
+ Terminal
+ </div>
+</a>
+
+ </div>
+
+
+ </div>
+
+</header>
+
+
+ <div class="content">
+
+<article class="post">
+ <h1 class="post-title">
+ <a href="http://localhost:1313/post/2018-09-11-shapeless/">Shapeless</a>
+ </h1>
+ <div class="post-meta"><time class="post-date">2018-09-11</time></div>
+
+
+ <span class="post-tags">
+
+ #<a href="http://localhost:1313/tags/shapeless/">shapeless</a>&nbsp;
+
+ #<a href="http://localhost:1313/tags/scala/">scala</a>&nbsp;
+
+ </span>
+
+
+
+
+
+
+ <div class="post-content"><div>
+ <p><a href="https://github.com/milessabin/shapeless">Shapeless</a></p>
+<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-scala" data-lang="scala"><span class="line"><span class="cl"><span class="k">import</span> <span class="nn">shapeless._</span>
+</span></span><span class="line"><span class="cl"><span class="k">import</span> <span class="nn">shapeless.ops.hlist.</span><span class="o">{</span><span class="nc">LiftAll</span><span class="o">,</span> <span class="nc">Mapper</span><span class="o">,</span> <span class="nc">Mapped</span><span class="o">}</span>
+</span></span><span class="line"><span class="cl"><span class="k">import</span> <span class="nn">shapeless.UnaryTCConstraint._</span>
+</span></span></code></pre></div>
+ </div></div>
+
+
+
+<div class="pagination">
+ <div class="pagination__title">
+ <span class="pagination__title-h"></span>
+ <hr />
+ </div>
+ <div class="pagination__buttons">
+
+ <a href="http://localhost:1313/post/fairstream/" class="button inline prev">
+ &lt; [<span class="button__text">Fairstream</span>]
+ </a>
+
+
+ ::
+
+
+ <a href="http://localhost:1313/post/2017-08-24-untyped-lambda-calculus/" class="button inline next">
+ [<span class="button__text">Untyped Lambda Calculus</span>] &gt;
+ </a>
+
+ </div>
+</div>
+
+
+
+
+
+
+
+
+</article>
+
+ </div>
+
+
+ <footer class="footer">
+ <div class="footer__inner">
+
+ <div class="copyright">
+ <span>© 2026 Powered by <a href="https://gohugo.io">Hugo</a></span>
+
+ <span>:: <a href="https://github.com/panr/hugo-theme-terminal" target="_blank">Theme</a> made by <a href="https://github.com/panr" target="_blank">panr</a></span>
+ </div>
+ </div>
+</footer>
+
+
+
+
+
+
+<script type="text/javascript" src="/bundle.min.js"></script>
+
+
+
+
+
+
+</div>
+
+</body>
+</html>
diff --git a/public/post/fairstream/index.html b/public/post/fairstream/index.html
new file mode 100644
index 0000000..26887df
--- /dev/null
+++ b/public/post/fairstream/index.html
@@ -0,0 +1,263 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+
+ <title>Fairstream :: </title>
+
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="description" content="Backtracking is a versatile approach for solving search problems by building solutions incrementally. If a partial solution cannot be extended, it is discarded and the process returns to a previous step to explore an alternative path. This method is generally more efficient than brute-force searching due to pruning: stopping exploration of a branch as soon as it violates a constraint, which eliminates entire sections of the search space.
+Strictly speaking, fair backtracking is not required for all search problems. A fair strategy guarantees all branches make progress, preventing any single branch from starving the others. The List monad handles non-deterministic computation well, and within a finite search space it produces the same results as a fair stream. When the search space is infinite, or when one branch may produce unbounded results, fairness becomes essential to ensure completeness.
+" />
+<meta name="keywords" content="" />
+
+ <meta name="robots" content="noodp" />
+
+<link rel="canonical" href="https://blog.gluegadget.com/post/fairstream/" />
+
+
+
+
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/buttons.min.86f6b4c106b6c6eb690ae5203d36b442c1f66f718ff4e8164fa86cf6c61ad641.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/code.min.d529ea4b2fb8d34328d7d31afc5466d5f7bc2f0bc9abdd98b69385335d7baee4.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/fonts.min.5bb7ed13e1d00d8ff39ea84af26737007eb5051b157b86fc24487c94f3dc8bbe.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/footer.min.eb8dfc2c6a7eafa36cd3ba92d63e69e849e2200e0002a228d137f236b09ecd75.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/gist.min.a751e8b0abe1ba8bc53ced52a38b19d8950fe78ca29454ea8c2595cf26aad5c0.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/header.min.75c7eb0e2872d95ff48109c6647d0223a38db52e2561dd87966eb5fc7c6bdac6.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/main.min.36833afd348409fc6c3d09d0897c5833d9d5bf1ff31f5e60ea3ee42ce2b1268c.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/menu.min.3c17467ebeb3d38663dce68f71f519901124fa5cbb4519b2fb0667a21e9aca39.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/pagination.min.bbb986dbce00a5ce5aca0504b7925fc1c581992a4bf57f163e5d69cc1db7d836.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/post.min.e6dddd258e64c83e05cec0cd49c05216742d42fc8ecbfbe6b67083412b609bd3.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/syntax.min.a0773cce9310cb6d8ed23e50f005448facf29a53001b57e038828daa466b25c0.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/terminal.min.e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/terms.min.b81791663c3790e738e571cdbf802312390d30e4b1d8dc9d814a5b5454d0ac11.css">
+
+
+
+
+
+
+
+<link rel="shortcut icon" href="https://blog.gluegadget.com/favicon.png">
+<link rel="apple-touch-icon" href="https://blog.gluegadget.com/apple-touch-icon.png">
+
+
+<meta name="twitter:card" content="summary" />
+
+
+
+<meta property="og:locale" content="en" />
+<meta property="og:type" content="article" />
+<meta property="og:title" content="Fairstream">
+<meta property="og:description" content="Backtracking is a versatile approach for solving search problems by building solutions incrementally. If a partial solution cannot be extended, it is discarded and the process returns to a previous step to explore an alternative path. This method is generally more efficient than brute-force searching due to pruning: stopping exploration of a branch as soon as it violates a constraint, which eliminates entire sections of the search space.
+Strictly speaking, fair backtracking is not required for all search problems. A fair strategy guarantees all branches make progress, preventing any single branch from starving the others. The List monad handles non-deterministic computation well, and within a finite search space it produces the same results as a fair stream. When the search space is infinite, or when one branch may produce unbounded results, fairness becomes essential to ensure completeness.
+" />
+<meta property="og:url" content="https://blog.gluegadget.com/post/fairstream/" />
+<meta property="og:site_name" content="" />
+
+ <meta property="og:image" content="https://blog.gluegadget.com/og-image.png">
+
+<meta property="og:image:width" content="1200">
+<meta property="og:image:height" content="627">
+
+
+ <meta property="article:published_time" content="2026-02-17 20:59:41 &#43;0000 UTC" />
+
+
+
+
+
+
+
+
+
+<script>
+window.MathJax = {
+ tex: {
+ inlineMath: [['$', '$'], ['\\(', '\\)']],
+ displayMath: [['$$', '$$'], ['\\[', '\\]']],
+ processEscapes: true,
+ processEnvironments: true
+ },
+ options: {
+ skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre']
+ }
+};
+</script>
+<script id="MathJax-script" async src="/mathjax/tex-mml-chtml.js"></script>
+
+
+</head>
+<body>
+
+
+<div class="container center">
+
+ <header class="header">
+ <div class="header__inner">
+ <div class="header__logo">
+ <a href="https://blog.gluegadget.com/">
+ <div class="logo">
+ Terminal
+ </div>
+</a>
+
+ </div>
+
+
+ </div>
+
+</header>
+
+
+ <div class="content">
+
+<article class="post">
+ <h1 class="post-title">
+ <a href="https://blog.gluegadget.com/post/fairstream/">Fairstream</a>
+ </h1>
+ <div class="post-meta"><time class="post-date">2026-02-17</time></div>
+
+
+
+
+
+
+
+ <div class="post-content"><div>
+ <p><a href="https://en.wikipedia.org/wiki/Backtracking">Backtracking</a> is a versatile approach for solving search problems by building solutions incrementally. If a partial solution cannot be extended, it is discarded and the process returns to a previous step to explore an alternative path. This method is generally more efficient than brute-force searching due to pruning: stopping exploration of a branch as soon as it violates a constraint, which eliminates entire sections of the search space.</p>
+<p>Strictly speaking, fair backtracking is not required for all search problems. A fair strategy guarantees all branches make progress, preventing any single branch from starving the others. The List monad handles non-deterministic computation well, and within a finite search space it produces the same results as a fair stream. When the search space is infinite, or when one branch may produce unbounded results, fairness becomes essential to ensure completeness.</p>
+<p><a href="https://github.com/codiff/fairstream"><code>fairstream</code></a> is a Scala implementation of fair backtracking based on the <a href="https://okmij.org/ftp/Computation/monads.html#fair-bt-stream">work</a> of Oleg Kiselyov.</p>
+<h2 id="the-problem-with-depth-first-search">The problem with depth-first search<a href="#the-problem-with-depth-first-search" class="hanchor" ariaLabel="Anchor">#</a> </h2>
+<p>Consider Pythagorean triples: tuples $(i, j, k)$ such that $i^2+j^2=k^2$, with $(3, 4, 5)$ as the canonical first example. If we try to generate all such triples using nested infinite generators, a conventional stream composition based on sequential <code>flatMap</code> gets stuck exploring an infinite branch that contains no solution and never comes back up to try a larger value, so it may fail to produce any triples at all despite solutions existing.</p>
+<p>The following example demonstrates how <a href="https://fs2.io/">fs2</a>.Stream&rsquo;s depth-first approach can fail to find Pythagorean triples, even though the result set is non-empty:</p>
+<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-scala" data-lang="scala"><span class="line"><span class="cl"><span class="k">val</span> <span class="n">number</span><span class="k">:</span> <span class="kt">fs2.Stream</span><span class="o">[</span><span class="kt">IO</span>, <span class="kt">Int</span><span class="o">]</span> <span class="k">=</span> <span class="n">fs2</span><span class="o">.</span><span class="nc">Stream</span><span class="o">.</span><span class="n">iterate</span><span class="o">(</span><span class="mi">1</span><span class="o">)(</span><span class="k">_</span> <span class="o">+</span> <span class="mi">1</span><span class="o">)</span>
+</span></span><span class="line"><span class="cl">
+</span></span><span class="line"><span class="cl"><span class="k">val</span> <span class="n">triples</span> <span class="k">=</span> <span class="k">for</span> <span class="o">{</span>
+</span></span><span class="line"><span class="cl"> <span class="n">i</span> <span class="k">&lt;-</span> <span class="n">number</span>
+</span></span><span class="line"><span class="cl"> <span class="n">j</span> <span class="k">&lt;-</span> <span class="n">number</span>
+</span></span><span class="line"><span class="cl"> <span class="n">k</span> <span class="k">&lt;-</span> <span class="n">number</span>
+</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="n">i</span> <span class="o">*</span> <span class="n">i</span> <span class="o">+</span> <span class="n">j</span> <span class="o">*</span> <span class="n">j</span> <span class="o">==</span> <span class="n">k</span> <span class="o">*</span> <span class="n">k</span>
+</span></span><span class="line"><span class="cl"><span class="o">}</span> <span class="k">yield</span> <span class="o">(</span><span class="n">i</span><span class="o">,</span> <span class="n">j</span><span class="o">,</span> <span class="n">k</span><span class="o">)</span>
+</span></span><span class="line"><span class="cl">
+</span></span><span class="line"><span class="cl"><span class="n">triples</span><span class="o">.</span><span class="n">take</span><span class="o">(</span><span class="mi">7</span><span class="o">).</span><span class="n">compile</span><span class="o">.</span><span class="n">toList</span>
+</span></span></code></pre></div><p>The <code>for</code> comprehension desugars into nested <code>flatMap</code> calls. Since <code>number</code> is infinite, the innermost generator tries $k = 1, 2, 3, \ldots$ forever for $i = 1, j = 1$ before it ever consider $j = 2$. No Pythagorean triple exists for $i = 1, j = 1$, so the stream never produces a result.</p>
+<p>This is not a quirk of ofs2. Any depth-first <code>flatMap</code> over infinite collections has this problem, including Scala&rsquo;s standard library <code>LazyList</code>.</p>
+<h2 id="fair-interleaving-with-fairstream">Fair interleaving with <code>fairstream</code><a href="#fair-interleaving-with-fairstream" class="hanchor" ariaLabel="Anchor">#</a> </h2>
+<p><code>fairstream</code> solves this by replacing sequential concatenation with fair disjuction (<code>mplus</code>), which interleaves branches so that every candidate is eventually reached.</p>
+<p>At the time of writing, the library is published as snapshots:</p>
+<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-scala" data-lang="scala"><span class="line"><span class="cl"><span class="n">resolvers</span> <span class="o">+=</span> <span class="nc">Resolver</span><span class="o">.</span><span class="n">sonatypeCentralSnapshots</span>
+</span></span><span class="line"><span class="cl">
+</span></span><span class="line"><span class="cl"><span class="n">libraryDependencies</span> <span class="o">+=</span> <span class="s">&#34;com.codiff&#34;</span> <span class="o">%%</span> <span class="s">&#34;fairstream&#34;</span> <span class="o">%</span> <span class="s">&#34;0.0-9f9db42-SNAPSHOT&#34;</span>
+</span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-scala" data-lang="scala"><span class="line"><span class="cl"><span class="k">import</span> <span class="nn">com.codiff.fairstream.Fair</span>
+</span></span><span class="line"><span class="cl"><span class="k">import</span> <span class="nn">com.codiff.fairstream.Fair._</span>
+</span></span><span class="line"><span class="cl">
+</span></span><span class="line"><span class="cl"><span class="k">lazy</span> <span class="k">val</span> <span class="n">number</span><span class="k">:</span> <span class="kt">Fair</span><span class="o">[</span><span class="kt">Int</span><span class="o">]</span> <span class="k">=</span> <span class="n">mplus</span><span class="o">(</span><span class="n">unit</span><span class="o">(</span><span class="mi">0</span><span class="o">),</span> <span class="n">number</span><span class="o">.</span><span class="n">map</span><span class="o">(</span><span class="k">_</span> <span class="o">+</span> <span class="mi">1</span><span class="o">))</span>
+</span></span><span class="line"><span class="cl">
+</span></span><span class="line"><span class="cl"><span class="k">val</span> <span class="n">triples</span> <span class="k">=</span> <span class="k">for</span> <span class="o">{</span>
+</span></span><span class="line"><span class="cl"> <span class="n">i</span> <span class="k">&lt;-</span> <span class="n">number</span>
+</span></span><span class="line"><span class="cl"> <span class="k">_</span> <span class="k">&lt;-</span> <span class="n">guard</span><span class="o">(</span><span class="n">i</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="o">)</span>
+</span></span><span class="line"><span class="cl"> <span class="n">j</span> <span class="k">&lt;-</span> <span class="n">number</span>
+</span></span><span class="line"><span class="cl"> <span class="k">_</span> <span class="k">&lt;-</span> <span class="n">guard</span><span class="o">(</span><span class="n">j</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="o">)</span>
+</span></span><span class="line"><span class="cl"> <span class="n">k</span> <span class="k">&lt;-</span> <span class="n">number</span>
+</span></span><span class="line"><span class="cl"> <span class="k">_</span> <span class="k">&lt;-</span> <span class="n">guard</span><span class="o">(</span><span class="n">k</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="o">)</span>
+</span></span><span class="line"><span class="cl"> <span class="k">_</span> <span class="k">&lt;-</span> <span class="n">guard</span><span class="o">(</span><span class="n">i</span> <span class="o">*</span> <span class="n">i</span> <span class="o">+</span> <span class="n">j</span> <span class="o">*</span> <span class="n">j</span> <span class="o">==</span> <span class="n">k</span> <span class="o">*</span> <span class="n">k</span><span class="o">)</span>
+</span></span><span class="line"><span class="cl"><span class="o">}</span> <span class="k">yield</span> <span class="o">(</span><span class="n">i</span><span class="o">,</span> <span class="n">j</span><span class="o">,</span> <span class="n">k</span><span class="o">)</span>
+</span></span><span class="line"><span class="cl">
+</span></span><span class="line"><span class="cl"><span class="nc">Fair</span><span class="o">.</span><span class="n">runM</span><span class="o">(</span><span class="nc">None</span><span class="o">,</span> <span class="nc">Some</span><span class="o">(</span><span class="mi">7</span><span class="o">),</span> <span class="n">triples</span><span class="o">)</span>
+</span></span></code></pre></div><h2 id="fairt-effectful-fair-backtracking"><code>FairT</code>: effectful fair backtracking<a href="#fairt-effectful-fair-backtracking" class="hanchor" ariaLabel="Anchor">#</a> </h2>
+<p><code>Fair[A]</code> is a pure computation. But what if your search branches need to perform effects, like reading from a database, calling an API, or logging? That&rsquo;s where <code>FairT[F[_], A]</code> comes in.</p>
+<p><code>FairT</code> is a monad transformer that layers fair backtracking on top of any effect <code>F</code>. This means you can interleave non-deterministic search with <code>IO</code>, <code>Task</code>, or any other cats-effect compatible monad.</p>
+<h2 id="fs2-integration">fs2 integration<a href="#fs2-integration" class="hanchor" ariaLabel="Anchor">#</a> </h2>
+<p>If you want to stay in the fs2 ecosystem, <code>fairstream-fs2</code> provides a conversion from <code>Fair</code> and <code>FairT</code> to <code>fs2.Stream</code>:</p>
+<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-scala" data-lang="scala"><span class="line"><span class="cl"><span class="n">libraryDependencies</span> <span class="o">+=</span> <span class="s">&#34;com.codiff&#34;</span> <span class="o">%%</span> <span class="s">&#34;fairstream-fs2&#34;</span> <span class="o">%</span> <span class="s">&#34;0.0-9f9db42-SNAPSHOT&#34;</span>
+</span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-scala" data-lang="scala"><span class="line"><span class="cl"><span class="k">import</span> <span class="nn">com.codiff.fairstream.fs2.syntax._</span>
+</span></span><span class="line"><span class="cl">
+</span></span><span class="line"><span class="cl"><span class="n">triples</span><span class="o">.</span><span class="n">toFs2</span><span class="o">.</span><span class="n">take</span><span class="o">(</span><span class="mi">7</span><span class="o">).</span><span class="n">compile</span><span class="o">.</span><span class="n">toList</span>
+</span></span></code></pre></div><p>This should let you compose fair backtracking with all the stream processing, concurrency, and resource management that fs2 provides. You define your search logic using <code>Fair</code> or <code>FairT</code>, then convert to <code>fs2.Stream</code> at the boundary where you need to integrate with the rest of your application.</p>
+
+ </div></div>
+
+
+
+<div class="pagination">
+ <div class="pagination__title">
+ <span class="pagination__title-h"></span>
+ <hr />
+ </div>
+ <div class="pagination__buttons">
+
+
+
+ <a href="https://blog.gluegadget.com/post/2017-08-22-thinkpad-e470/" class="button inline next">
+ [<span class="button__text">ThinkPad E470</span>] &gt;
+ </a>
+
+ </div>
+</div>
+
+
+
+
+
+
+
+
+</article>
+
+ </div>
+
+
+ <footer class="footer">
+ <div class="footer__inner">
+
+ <div class="copyright">
+ <span>© 2026 Powered by <a href="https://gohugo.io">Hugo</a></span>
+
+ <span>:: <a href="https://github.com/panr/hugo-theme-terminal" target="_blank">Theme</a> made by <a href="https://github.com/panr" target="_blank">panr</a></span>
+ </div>
+ </div>
+</footer>
+
+
+
+
+
+
+<script type="text/javascript" src="/bundle.min.js"></script>
+
+
+
+
+
+
+</div>
+
+</body>
+</html>
diff --git a/public/post/index.html b/public/post/index.html
index 54bac6a..0377429 100644
--- a/public/post/index.html
+++ b/public/post/index.html
@@ -1,159 +1,270 @@
<!DOCTYPE html>
<html lang="en">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
-
- <title></title>
- <meta name="viewport" content="width=device-width,minimum-scale=1">
- <meta name="description" content="">
- <meta name="generator" content="Hugo 0.155.0">
-
-
-
- <meta name="robots" content="index, follow">
-
-
+<head>
+
+ <title>Posts :: </title>
+
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="description" content="" />
+<meta name="keywords" content="" />
-
-<link rel="stylesheet" href="/ananke/css/main.min.efe4d852f731d5d1fbb87718387202a97aafd768cdcdaed0662bbe6982e91824.css" >
+ <meta name="robots" content="noodp" />
+<link rel="canonical" href="https://blog.gluegadget.com/post/" />
-
-
-
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/buttons.min.86f6b4c106b6c6eb690ae5203d36b442c1f66f718ff4e8164fa86cf6c61ad641.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/code.min.d529ea4b2fb8d34328d7d31afc5466d5f7bc2f0bc9abdd98b69385335d7baee4.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/fonts.min.5bb7ed13e1d00d8ff39ea84af26737007eb5051b157b86fc24487c94f3dc8bbe.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/footer.min.eb8dfc2c6a7eafa36cd3ba92d63e69e849e2200e0002a228d137f236b09ecd75.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/gist.min.a751e8b0abe1ba8bc53ced52a38b19d8950fe78ca29454ea8c2595cf26aad5c0.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/header.min.75c7eb0e2872d95ff48109c6647d0223a38db52e2561dd87966eb5fc7c6bdac6.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/main.min.36833afd348409fc6c3d09d0897c5833d9d5bf1ff31f5e60ea3ee42ce2b1268c.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/menu.min.3c17467ebeb3d38663dce68f71f519901124fa5cbb4519b2fb0667a21e9aca39.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/pagination.min.bbb986dbce00a5ce5aca0504b7925fc1c581992a4bf57f163e5d69cc1db7d836.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/post.min.e6dddd258e64c83e05cec0cd49c05216742d42fc8ecbfbe6b67083412b609bd3.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/syntax.min.a0773cce9310cb6d8ed23e50f005448facf29a53001b57e038828daa466b25c0.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/terminal.min.e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css">
+
+
+ <link rel="stylesheet" href="https://blog.gluegadget.com/css/terms.min.b81791663c3790e738e571cdbf802312390d30e4b1d8dc9d814a5b5454d0ac11.css">
+
+
-
-
-
- <link href="/post/index.xml" rel="alternate" type="application/rss+xml" title="" />
- <link href="/post/index.xml" rel="feed" type="application/rss+xml" title="" />
-
-
-
- <link rel="canonical" href="https://blog.gluegadget.com/post/">
-
+
+<link rel="shortcut icon" href="https://blog.gluegadget.com/favicon.png">
+<link rel="apple-touch-icon" href="https://blog.gluegadget.com/apple-touch-icon.png">
+
+
+<meta name="twitter:card" content="summary" />
+
+
+
+<meta property="og:locale" content="en" />
+<meta property="og:type" content="website" />
+<meta property="og:title" content="Posts">
+<meta property="og:description" content="" />
+<meta property="og:url" content="https://blog.gluegadget.com/post/" />
+<meta property="og:site_name" content="" />
+
+ <meta property="og:image" content="https://blog.gluegadget.com/og-image.png">
+
+<meta property="og:image:width" content="1200">
+<meta property="og:image:height" content="627">
+
+
+
+
+
+ <link href="/post/index.xml" rel="alternate" type="application/rss+xml" title="" />
+
+
+
+
+
+
+<script>
+window.MathJax = {
+ tex: {
+ inlineMath: [['$', '$'], ['\\(', '\\)']],
+ displayMath: [['$$', '$$'], ['\\[', '\\]']],
+ processEscapes: true,
+ processEnvironments: true
+ },
+ options: {
+ skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre']
+ }
+};
+</script>
+<script id="MathJax-script" async src="/mathjax/tex-mml-chtml.js"></script>
+
+
+</head>
+<body>
+
+
+<div class="container center">
+
+ <header class="header">
+ <div class="header__inner">
+ <div class="header__logo">
+ <a href="https://blog.gluegadget.com/">
+ <div class="logo">
+ Terminal
+ </div>
+</a>
+
+ </div>
- <meta property="og:url" content="https://blog.gluegadget.com/post/">
- <meta property="og:title" content="Posts">
- <meta property="og:locale" content="en">
- <meta property="og:type" content="website">
-
- <meta itemprop="name" content="Posts">
- <meta itemprop="datePublished" content="2017-08-22T00:00:00+00:00">
- <meta itemprop="dateModified" content="2017-08-22T00:00:00+00:00">
- <meta name="twitter:card" content="summary">
- <meta name="twitter:title" content="Posts">
-
-
-
+ </div>
+
+</header>
+
+
+ <div class="content">
-
- </head><body class="ma0 avenir bg-near-white production is-section is-section">
+
+ <div class="posts">
+ <article class="post on-list">
+ <h2 class="post-title">
+ <a href="https://blog.gluegadget.com/post/fairstream/">Fairstream</a>
+ </h2>
+ <div class="post-meta"><time class="post-date">2026-02-17</time></div>
- <header>
- <div class="pb3-m pb6-l bg-black">
- <nav class="pv3 ph3 ph4-ns" role="navigation">
- <div class="flex-l center items-center justify-between">
- <a href="/" class="f3 fw2 hover-white white-90 dib no-underline">
-
-
- </a>
- <div class="flex-l items-center">
-
-
- <div class="ananke-socials"></div>
+
- </div>
- </div>
-</nav>
- <div class="tc-l pv3 ph3 ph4-ns">
- <h1 class="f2 f-subheadline-l fw2 light-silver mb0 lh-title">
- Posts
- </h1>
+ <div class="post-content">
+
+ <p><a href="https://en.wikipedia.org/wiki/Backtracking">Backtracking</a> is a versatile approach for solving search problems by building solutions incrementally. If a partial solution cannot be extended, it is discarded and the process returns to a previous step to explore an alternative path. This method is generally more efficient than brute-force searching due to pruning: stopping exploration of a branch as soon as it violates a constraint, which eliminates entire sections of the search space.</p>
+<p>Strictly speaking, fair backtracking is not required for all search problems. A fair strategy guarantees all branches make progress, preventing any single branch from starving the others. The List monad handles non-deterministic computation well, and within a finite search space it produces the same results as a fair stream. When the search space is infinite, or when one branch may produce unbounded results, fairness becomes essential to ensure completeness.</p>
+
+ </div>
+
- </div>
- </div>
- </header>
+ <div>
+ <a class="read-more button inline" href="/post/fairstream/">[]</a>
+ </div>
+
+ </article>
+
+ <article class="post on-list">
+ <h2 class="post-title">
+ <a href="https://blog.gluegadget.com/post/2017-08-22-thinkpad-e470/">ThinkPad E470</a>
+ </h2>
+ <div class="post-meta"><time class="post-date">2017-08-22</time></div>
+
+ <span class="post-tags">
+
+ #<a href="https://blog.gluegadget.com/tags/thinkpad/">thinkpad</a>&nbsp;
+
+ #<a href="https://blog.gluegadget.com/tags/e470/">e470</a>&nbsp;
+
+ </span>
+
- <main class="pb7" role="main">
-
+
- <article class="pa3 pa4-ns nested-copy-line-height">
- <section class="cf ph3 ph5-l pv3 pv4-l f4 tc-l center measure-wide lh-copy nested-links mid-gray">
-
- </section>
- <aside class="flex-ns mt5 flex-wrap justify-around">
-
- <div class="w-100 w-30-l mb4 relative bg-white">
- <div class="mb3 pa4 mid-gray overflow-hidden">
-
- <div class="f6">
- August 22, 2017
- </div>
-
- <h1 class="f3 near-black">
- <a href="/post/2017-08-22-thinkpad-e470/" class="link black dim">
- ThinkPad E470
- </a>
- </h1>
- <div class="nested-links f5 lh-copy nested-copy-line-height">
- <p>Recently I&rsquo;ve been looking for a Linux-friendly, budget laptop. I like ThinkPads, and all of my laptops have been either T-series or X-series but this time I didn&rsquo;t want to spend that amount of money and was looking for cheaper alternatives.</p>
+
+ <div class="post-content">
+
+ <p>Recently I&rsquo;ve been looking for a Linux-friendly, budget laptop. I like ThinkPads, and all of my laptops have been either T-series or X-series but this time I didn&rsquo;t want to spend that amount of money and was looking for cheaper alternatives.</p>
<p>Browsing Lenovo website, I realised that a reasonably configured <a href="http://www3.lenovo.com/ie/en/laptops/thinkpad/edge-series/E470/p/22TP2TEE470">E470</a> would cost about €1000 which was about how much I was willing to pay. I configured it, so it has:</p>
- </div>
- <a href="/post/2017-08-22-thinkpad-e470/" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">read more</a>
- </div>
+
+ </div>
+
+
+ <div>
+ <a class="read-more button inline" href="/post/2017-08-22-thinkpad-e470/">[]</a>
+ </div>
+
+ </article>
+
+ <article class="post on-list">
+ <h2 class="post-title">
+ <a href="https://blog.gluegadget.com/post/2017-08-16-tapl/">Types and Programming Languages</a>
+ </h2>
+ <div class="post-meta"><time class="post-date">2017-08-16</time></div>
+
+
+ <span class="post-tags">
+
+ #<a href="https://blog.gluegadget.com/tags/tapl/">tapl</a>&nbsp;
+
+ #<a href="https://blog.gluegadget.com/tags/rust/">rust</a>&nbsp;
+
+ </span>
+
+
+
+
+ <div class="post-content">
+
+ <p>February 2016, as a birthday present to myself I bought a copy of <a href="https://www.cis.upenn.edu/~bcpierce/tapl/">Types and Programming Languages</a>. At the time the only thing I did with it was to take a photo of it, sharing it on Twitter and congratulating myself. To be fair, I did try reading it, but it was so intimidating that I gave up very early in the book. One and a half years later I’m going to give it another go because a few things have changed.</p>
+
</div>
-
- <div class="w-100 w-30-l mb4 relative bg-white">
- <div class="mb3 pa4 mid-gray overflow-hidden">
+
+
+ <div>
+ <a class="read-more button inline" href="/post/2017-08-16-tapl/">[]</a>
+ </div>
+
+ </article>
+
+
+ <div class="pagination">
+ <div class="pagination__buttons">
+
- <div class="f6">
- August 16, 2017
- </div>
- <h1 class="f3 near-black">
- <a href="/post/2017-08-16-tapl/" class="link black dim">
- Types and Programming Languages
- </a>
- </h1>
- <div class="nested-links f5 lh-copy nested-copy-line-height">
- <p>February 2016, as a birthday present to myself I bought a copy of <a href="https://www.cis.upenn.edu/~bcpierce/tapl/">Types and Programming Languages</a>. At the time the only thing I did with it was to take a photo of it, sharing it on Twitter and congratulating myself. To be fair, I did try reading it, but it was so intimidating that I gave up very early in the book. One and a half years later I’m going to give it another go because a few things have changed.</p>
- </div>
- <a href="/post/2017-08-16-tapl/" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">read more</a>
</div>
+</div>
- </div>
-
- </aside>
+ </div>
+
+ </div>
+
+
+ <footer class="footer">
+ <div class="footer__inner">
+ <div class="copyright">
+ <span>© 2026 Powered by <a href="https://gohugo.io">Hugo</a></span>
- </article>
-
- </main>
- <footer class="bg-black bottom-0 w-100 pa3" role="contentinfo">
- <div class="flex justify-between">
- <a class="f4 fw4 hover-white white-70 dn dib-ns pv2 ph3 no-underline" href="https://blog.gluegadget.com/" >
- &copy;
- </a>
- <div><div class="ananke-socials"></div>
-</div>
+ <span>:: <a href="https://github.com/panr/hugo-theme-terminal" target="_blank">Theme</a> made by <a href="https://github.com/panr" target="_blank">panr</a></span>
+ </div>
</div>
</footer>
- </body>
+
+
+
+
+
+<script type="text/javascript" src="/bundle.min.js"></script>
+
+
+
+
+
+
+</div>
+
+</body>
</html>
diff --git a/public/post/index.xml b/public/post/index.xml
index bd08f3a..85cb7be 100644
--- a/public/post/index.xml
+++ b/public/post/index.xml
@@ -6,9 +6,16 @@
<description>Recent content in Posts on </description>
<generator>Hugo</generator>
<language>en</language>
- <lastBuildDate>Tue, 22 Aug 2017 00:00:00 +0000</lastBuildDate>
+ <lastBuildDate>Tue, 17 Feb 2026 20:59:41 +0000</lastBuildDate>
<atom:link href="https://blog.gluegadget.com/post/index.xml" rel="self" type="application/rss+xml" />
<item>
+ <title>Fairstream</title>
+ <link>https://blog.gluegadget.com/post/fairstream/</link>
+ <pubDate>Tue, 17 Feb 2026 20:59:41 +0000</pubDate>
+ <guid>https://blog.gluegadget.com/post/fairstream/</guid>
+ <description>&lt;p&gt;&lt;a href=&#34;https://en.wikipedia.org/wiki/Backtracking&#34;&gt;Backtracking&lt;/a&gt; is a versatile approach for solving search problems by building solutions incrementally. If a partial solution cannot be extended, it is discarded and the process returns to a previous step to explore an alternative path. This method is generally more efficient than brute-force searching due to pruning: stopping exploration of a branch as soon as it violates a constraint, which eliminates entire sections of the search space.&lt;/p&gt;&#xA;&lt;p&gt;Strictly speaking, fair backtracking is not required for all search problems. A fair strategy guarantees all branches make progress, preventing any single branch from starving the others. The List monad handles non-deterministic computation well, and within a finite search space it produces the same results as a fair stream. When the search space is infinite, or when one branch may produce unbounded results, fairness becomes essential to ensure completeness.&lt;/p&gt;</description>
+ </item>
+ <item>
<title>ThinkPad E470</title>
<link>https://blog.gluegadget.com/post/2017-08-22-thinkpad-e470/</link>
<pubDate>Tue, 22 Aug 2017 00:00:00 +0000</pubDate>
diff --git a/public/post/simple-fair-and-terminating-backtracking-monad-transformer/index.html b/public/post/simple-fair-and-terminating-backtracking-monad-transformer/index.html
new file mode 100644
index 0000000..40a74a1
--- /dev/null
+++ b/public/post/simple-fair-and-terminating-backtracking-monad-transformer/index.html
@@ -0,0 +1,258 @@
+<!DOCTYPE html>
+<html lang="en">
+<head><script src="/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=livereload" data-no-instant defer></script>
+
+ <title>Simple Fair and Terminating Backtracking Monad Transformer :: </title>
+
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="description" content="About eight years ago as part of an interview process I was given a take home code challenge. Considering how much it&rsquo;s changed in the tech world and the fact that company is no longer hirigin I feel comfortable sharing the details of the challenge.
+You run a paint shop, and there are a few different colors of paint you can prepare. Each color can be either &ldquo;gloss&rdquo; or &ldquo;matte&rdquo;. You have a number of customers, and each have some colors they like, either gloss or matte. No customer will like more than one color in matte You want to mix the colors, so that:
+" />
+<meta name="keywords" content="" />
+
+ <meta name="robots" content="noodp" />
+
+<link rel="canonical" href="http://localhost:1313/post/simple-fair-and-terminating-backtracking-monad-transformer/" />
+
+
+
+
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/buttons.min.86f6b4c106b6c6eb690ae5203d36b442c1f66f718ff4e8164fa86cf6c61ad641.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/code.min.d529ea4b2fb8d34328d7d31afc5466d5f7bc2f0bc9abdd98b69385335d7baee4.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/fonts.min.5bb7ed13e1d00d8ff39ea84af26737007eb5051b157b86fc24487c94f3dc8bbe.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/footer.min.eb8dfc2c6a7eafa36cd3ba92d63e69e849e2200e0002a228d137f236b09ecd75.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/gist.min.a751e8b0abe1ba8bc53ced52a38b19d8950fe78ca29454ea8c2595cf26aad5c0.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/header.min.75c7eb0e2872d95ff48109c6647d0223a38db52e2561dd87966eb5fc7c6bdac6.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/main.min.36833afd348409fc6c3d09d0897c5833d9d5bf1ff31f5e60ea3ee42ce2b1268c.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/menu.min.3c17467ebeb3d38663dce68f71f519901124fa5cbb4519b2fb0667a21e9aca39.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/pagination.min.bbb986dbce00a5ce5aca0504b7925fc1c581992a4bf57f163e5d69cc1db7d836.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/post.min.e6dddd258e64c83e05cec0cd49c05216742d42fc8ecbfbe6b67083412b609bd3.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/syntax.min.a0773cce9310cb6d8ed23e50f005448facf29a53001b57e038828daa466b25c0.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/terminal.min.e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css">
+
+
+ <link rel="stylesheet" href="http://localhost:1313/css/terms.min.b81791663c3790e738e571cdbf802312390d30e4b1d8dc9d814a5b5454d0ac11.css">
+
+
+
+
+
+
+
+<link rel="shortcut icon" href="http://localhost:1313/favicon.png">
+<link rel="apple-touch-icon" href="http://localhost:1313/apple-touch-icon.png">
+
+
+<meta name="twitter:card" content="summary" />
+
+
+
+<meta property="og:locale" content="en" />
+<meta property="og:type" content="article" />
+<meta property="og:title" content="Simple Fair and Terminating Backtracking Monad Transformer">
+<meta property="og:description" content="About eight years ago as part of an interview process I was given a take home code challenge. Considering how much it&rsquo;s changed in the tech world and the fact that company is no longer hirigin I feel comfortable sharing the details of the challenge.
+You run a paint shop, and there are a few different colors of paint you can prepare. Each color can be either &ldquo;gloss&rdquo; or &ldquo;matte&rdquo;. You have a number of customers, and each have some colors they like, either gloss or matte. No customer will like more than one color in matte You want to mix the colors, so that:
+" />
+<meta property="og:url" content="http://localhost:1313/post/simple-fair-and-terminating-backtracking-monad-transformer/" />
+<meta property="og:site_name" content="" />
+
+ <meta property="og:image" content="http://localhost:1313/og-image.png">
+
+<meta property="og:image:width" content="1200">
+<meta property="og:image:height" content="627">
+
+
+ <meta property="article:published_time" content="2026-02-16 20:26:32 &#43;0000 UTC" />
+
+
+
+
+
+
+
+
+
+
+
+
+</head>
+<body>
+
+
+<div class="container center">
+
+ <header class="header">
+ <div class="header__inner">
+ <div class="header__logo">
+ <a href="http://localhost:1313/">
+ <div class="logo">
+ Terminal
+ </div>
+</a>
+
+ </div>
+
+
+ </div>
+
+</header>
+
+
+ <div class="content">
+
+<article class="post">
+ <h1 class="post-title">
+ <a href="http://localhost:1313/post/simple-fair-and-terminating-backtracking-monad-transformer/">Simple Fair and Terminating Backtracking Monad Transformer</a>
+ </h1>
+ <div class="post-meta"><time class="post-date">2026-02-16</time></div>
+
+
+
+
+
+
+
+ <div class="post-content"><div>
+ <p>About eight years ago as part of an interview process I was given a take home code challenge. Considering how much it&rsquo;s changed in the tech world and the fact that company is no longer hirigin I feel comfortable sharing the details of the challenge.</p>
+<blockquote>
+<p>You run a paint shop, and there are a few different colors of paint you can prepare. Each color can be either &ldquo;gloss&rdquo; or &ldquo;matte&rdquo;.
+You have a number of customers, and each have some colors they like, either gloss or matte. No customer will like more than one color in matte
+You want to mix the colors, so that:</p>
+<ul>
+<li>There is just one batch for each color, and it&rsquo;s either gloss or matte.</li>
+<li>For each customer, there is at least one color they like.</li>
+<li>You make as few mattes as possible (because they are more expensive).
+Your program should accept an input file as a command line argument, and print a result to standard out. An example input file is:</li>
+</ul>
+<p>5 <!-- raw HTML omitted --><br>
+1 M 3 G 5 G <!-- raw HTML omitted --><br>
+2 G 3 M 4 G <!-- raw HTML omitted --><br>
+5 M <!-- raw HTML omitted --></p>
+<p>The first line specifies how many colors there are.</p>
+<p>Each subsequent line describes a customer. For example, the first customer likes color 1 in matte, color 3 in gloss and color 5 in gloss.</p>
+<p>Your program should read an input file like this, and print out either that it is impossible to satisfy all the customer, or describe, for each of the colors, whether it should be made gloss or matte.</p>
+<p>The output for the above file should be:</p>
+<p>G G G G M</p>
+</blockquote>
+<pre tabindex="0"><code class="language-sbt" data-lang="sbt">resolvers += Resolver.sonatypeCentralSnapshots
+libraryDependencies += &#34;com.codiff&#34; %% &#34;fairstream&#34; % &#34;0.0-9f9db42-SNAPSHOT&#34;
+</code></pre><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-scala" data-lang="scala"><span class="line"><span class="cl"><span class="k">import</span> <span class="nn">com.codiff.fairstream.Fair._</span>
+</span></span><span class="line"><span class="cl">
+</span></span><span class="line"><span class="cl"><span class="k">sealed</span> <span class="k">trait</span> <span class="nc">Finish</span>
+</span></span><span class="line"><span class="cl"><span class="k">final</span> <span class="k">case</span> <span class="k">object</span> <span class="nc">Gloss</span> <span class="k">extends</span> <span class="nc">Finish</span>
+</span></span><span class="line"><span class="cl"><span class="k">final</span> <span class="k">case</span> <span class="k">object</span> <span class="nc">Matte</span> <span class="k">extends</span> <span class="nc">Finish</span>
+</span></span><span class="line"><span class="cl">
+</span></span><span class="line"><span class="cl"><span class="k">final</span> <span class="k">case</span> <span class="k">class</span> <span class="nc">Color</span><span class="o">(</span><span class="n">id</span><span class="k">:</span> <span class="kt">Int</span><span class="o">)</span>
+</span></span><span class="line"><span class="cl">
+</span></span><span class="line"><span class="cl"><span class="k">final</span> <span class="k">case</span> <span class="k">class</span> <span class="nc">Paint</span><span class="o">(</span><span class="n">color</span><span class="k">:</span> <span class="kt">Color</span><span class="o">,</span> <span class="n">finish</span><span class="k">:</span> <span class="kt">Finish</span><span class="o">)</span>
+</span></span><span class="line"><span class="cl">
+</span></span><span class="line"><span class="cl"><span class="k">def</span> <span class="n">solve</span><span class="o">(</span>
+</span></span><span class="line"><span class="cl"> <span class="n">numColors</span><span class="k">:</span> <span class="kt">Int</span><span class="o">,</span>
+</span></span><span class="line"><span class="cl"> <span class="n">customers</span><span class="k">:</span> <span class="kt">List</span><span class="o">[</span><span class="kt">List</span><span class="o">[</span><span class="kt">Paint</span><span class="o">]]</span>
+</span></span><span class="line"><span class="cl"><span class="o">)</span><span class="k">:</span> <span class="kt">Option</span><span class="o">[</span><span class="kt">Vector</span><span class="o">[</span><span class="kt">Finish</span><span class="o">]]</span> <span class="k">=</span> <span class="o">{</span>
+</span></span><span class="line"><span class="cl">
+</span></span><span class="line"><span class="cl"> <span class="k">def</span> <span class="n">go</span><span class="o">(</span><span class="n">color</span><span class="k">:</span> <span class="kt">Int</span><span class="o">,</span> <span class="n">assignment</span><span class="k">:</span> <span class="kt">Vector</span><span class="o">[</span><span class="kt">Finish</span><span class="o">])</span><span class="k">:</span> <span class="kt">Fair</span><span class="o">[</span><span class="kt">Vector</span><span class="o">[</span><span class="kt">Finish</span><span class="o">]]</span> <span class="k">=</span> <span class="o">{</span>
+</span></span><span class="line"><span class="cl"> <span class="c1">// Prune early: if any customer&#39;s preferences are all decided and none match
+</span></span></span><span class="line"><span class="cl"> <span class="k">val</span> <span class="n">dominated</span> <span class="k">=</span> <span class="n">customers</span><span class="o">.</span><span class="n">exists</span> <span class="o">{</span> <span class="n">prefs</span> <span class="k">=&gt;</span>
+</span></span><span class="line"><span class="cl"> <span class="n">prefs</span><span class="o">.</span><span class="n">nonEmpty</span> <span class="o">&amp;&amp;</span> <span class="n">prefs</span><span class="o">.</span><span class="n">forall</span> <span class="o">{</span> <span class="n">p</span> <span class="k">=&gt;</span>
+</span></span><span class="line"><span class="cl"> <span class="n">p</span><span class="o">.</span><span class="n">color</span> <span class="o">&lt;=</span> <span class="n">assignment</span><span class="o">.</span><span class="n">length</span> <span class="o">&amp;&amp;</span> <span class="n">assignment</span><span class="o">(</span><span class="n">p</span><span class="o">.</span><span class="n">color</span> <span class="o">-</span> <span class="mi">1</span><span class="o">)</span> <span class="o">!=</span> <span class="n">p</span><span class="o">.</span><span class="n">finish</span>
+</span></span><span class="line"><span class="cl"> <span class="o">}</span>
+</span></span><span class="line"><span class="cl"> <span class="o">}</span>
+</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="o">(</span><span class="n">dominated</span><span class="o">)</span> <span class="n">empty</span>
+</span></span><span class="line"><span class="cl"> <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="n">color</span> <span class="o">&gt;</span> <span class="n">numColors</span><span class="o">)</span> <span class="n">unit</span><span class="o">(</span><span class="n">assignment</span><span class="o">)</span>
+</span></span><span class="line"><span class="cl"> <span class="k">else</span>
+</span></span><span class="line"><span class="cl"> <span class="n">mplus</span><span class="o">(</span>
+</span></span><span class="line"><span class="cl"> <span class="n">go</span><span class="o">(</span><span class="n">color</span> <span class="o">+</span> <span class="mi">1</span><span class="o">,</span> <span class="n">assignment</span> <span class="k">:</span><span class="kt">+</span> <span class="kt">Gloss</span><span class="o">),</span>
+</span></span><span class="line"><span class="cl"> <span class="n">go</span><span class="o">(</span><span class="n">color</span> <span class="o">+</span> <span class="mi">1</span><span class="o">,</span> <span class="n">assignment</span> <span class="k">:</span><span class="kt">+</span> <span class="kt">Matte</span><span class="o">)</span>
+</span></span><span class="line"><span class="cl"> <span class="o">)</span>
+</span></span><span class="line"><span class="cl"> <span class="o">}</span>
+</span></span><span class="line"><span class="cl">
+</span></span><span class="line"><span class="cl"> <span class="c1">// Enumerate all valid assignments, pick the one with fewest mattes
+</span></span></span><span class="line"><span class="cl"> <span class="k">val</span> <span class="n">solutions</span> <span class="k">=</span> <span class="nc">Fair</span><span class="o">.</span><span class="n">runM</span><span class="o">(</span><span class="nc">None</span><span class="o">,</span> <span class="nc">None</span><span class="o">,</span> <span class="n">go</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="nc">Vector</span><span class="o">.</span><span class="n">empty</span><span class="o">))</span>
+</span></span><span class="line"><span class="cl"> <span class="n">solutions</span><span class="o">.</span><span class="n">minByOption</span><span class="o">(</span><span class="k">_</span><span class="o">.</span><span class="n">count</span><span class="o">(</span><span class="k">_</span> <span class="o">==</span> <span class="nc">Matte</span><span class="o">))</span>
+</span></span><span class="line"><span class="cl"><span class="o">}</span>
+</span></span></code></pre></div>
+ </div></div>
+
+
+
+<div class="pagination">
+ <div class="pagination__title">
+ <span class="pagination__title-h"></span>
+ <hr />
+ </div>
+ <div class="pagination__buttons">
+
+
+
+ <a href="http://localhost:1313/post/2018-09-11-shapeless/" class="button inline next">
+ [<span class="button__text">Shapeless</span>] &gt;
+ </a>
+
+ </div>
+</div>
+
+
+
+
+
+
+
+
+</article>
+
+ </div>
+
+
+ <footer class="footer">
+ <div class="footer__inner">
+
+ <div class="copyright">
+ <span>© 2026 Powered by <a href="https://gohugo.io">Hugo</a></span>
+
+ <span>:: <a href="https://github.com/panr/hugo-theme-terminal" target="_blank">Theme</a> made by <a href="https://github.com/panr" target="_blank">panr</a></span>
+ </div>
+ </div>
+</footer>
+
+
+
+
+
+
+<script type="text/javascript" src="/bundle.min.js"></script>
+
+
+
+
+
+
+</div>
+
+</body>
+</html>