]> git.taranathan.com Git - blog.git/commitdiff
stuff main
authormoo <moogoesmeow123@gmail.com>
Thu, 3 Sep 2026 23:28:42 +0000 (16:28 -0700)
committermoo <moogoesmeow123@gmail.com>
Thu, 3 Sep 2026 23:28:42 +0000 (16:28 -0700)
content/blog/pipes.md [new file with mode: 0644]
public/blog/gleam/index.html
public/blog/index.html
public/blog/pipes/index.html [new file with mode: 0644]
public/miniblog/index.html
public/miniblog/pipes/index.html
public/sitemap.xml
templates/main-page.html [deleted file]

diff --git a/content/blog/pipes.md b/content/blog/pipes.md
new file mode 100644 (file)
index 0000000..32c2735
--- /dev/null
@@ -0,0 +1,45 @@
++++
+title = "pipes"
+date = 2026-06-22
++++
+
+Huh. I was just thinking about how cool a pipe operator would be in rust, and about method-chaining when I realized that they are both kind of the same thing! For example, look at these rust and gleam (a language with a very similar syntax):
+
+```rust
+//rust
+let result: Result<i32> = fallible_operation();
+let output = result
+  .map(add_one)
+  .map(add_one)
+  .map(add_one)
+  .unwrap_or(0);
+```
+
+<br>
+
+```gleam
+//gleam
+let result: Result(Int) = fallible_operation()
+let output = result
+  |> result.map(add_one)
+  |> result.map(add_one)
+  |> result.map(add_one)
+  |> result.unwrap(0)
+```
+
+When they are formatted this way, don't they look *pretttty* similar? That's because, they are, by definition, the exact same thing. If you look into the function signatures behind any `impl` method/function in rust, they all start with an `&self` or some variation because the dot notation is actually just syntax sugar. If I wanted to write out the rust example the long way, I could've done it like this:
+
+```rust
+// the type of std::result::unwrap_or is fn(self, F) -> Result<U, E>,
+// but in dot notation the first argument is omitted, like in a pipe operator
+
+let result: Result<i32> = fallible_operation();
+let output = std::result::Result::unwrap_or(
+  std::result::Result::map(
+  std::result::Result::map(
+  std::result::Result::map(&result, add_one), add_one), add_one),
+  0);
+```
+
+And the pipe operator in so many functional languages also serves the same purpose: as syntax sugar. Anyways, I just found this kind of neat, and my guess as to a little bit about why there isn't a pipe operator in rust yet, despite taking so much heavy influence from functional languages like OCaml. 
+
index bb47f43ed3628ee51e4133ce7fefb6ff32b2b85f..f255e33de0b5c99e699095831098386767052544 100644 (file)
@@ -31,7 +31,7 @@
     <h1 class="title">gleam</h1>
     <p class="subtitle"><strong>2026-06-15</strong></p>
     <div class="post-content"><p>Last wednesday, when I was boarding my flight to Junior Men’s National Team field hockey tryouts(wish me luck!), I started to try out the Gleam programming language. It is really fascinating. It looks like rust(without mutability or imperativeness), but compiles down to erlang and javascript. It also has a bunch of quality of life features for functional programming that I would love to have in rust, like the pipe operator or the ease of its partial function application. For example, in gleam, you can just do this to partially apply a function:</p>
-<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;"><code data-lang="gleam"><span class="giallo-l"><span style="color: #CBA6F7;">fn</span><span style="color: #89B4FA;font-style: italic;"> add</span><span>(</span><span style="color: #EBA0AC;font-style: italic;">x: </span><span style="color: #F9E2AF;font-style: italic;">Int</span><span>, </span><span style="color: #EBA0AC;font-style: italic;">y: </span><span style="color: #F9E2AF;font-style: italic;">Int</span><span>)</span><span style="color: #94E2D5;"> -&gt;</span><span style="color: #F9E2AF;font-style: italic;"> Int</span><span> {</span></span>
+<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;" ><code data-lang="gleam"><span class="giallo-l"><span style="color: #CBA6F7;">fn</span><span style="color: #89B4FA;font-style: italic;"> add</span><span>(</span><span style="color: #EBA0AC;font-style: italic;">x: </span><span style="color: #F9E2AF;font-style: italic;">Int</span><span>, </span><span style="color: #EBA0AC;font-style: italic;">y: </span><span style="color: #F9E2AF;font-style: italic;">Int</span><span>)</span><span style="color: #94E2D5;"> -&gt;</span><span style="color: #F9E2AF;font-style: italic;"> Int</span><span> {</span></span>
 <span class="giallo-l"><span>  x </span><span style="color: #94E2D5;">+</span><span> y</span></span>
 <span class="giallo-l"><span>}</span></span>
 <span class="giallo-l"></span>
 <span class="giallo-l"><span style="color: #CBA6F7;">  assert</span><span style="color: #89B4FA;font-style: italic;"> add_one</span><span>(</span><span style="color: #FAB387;">3</span><span>)</span><span style="color: #94E2D5;"> ==</span><span style="color: #FAB387;"> 4</span></span>
 <span class="giallo-l"><span>}</span></span></code></pre>
 <p>It’s so simple! Also, the pipe operator works just like you’d expect from any other functional language:</p>
-<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;"><code data-lang="gleam"><span class="giallo-l"><span style="color: #CBA6F7;">fn</span><span style="color: #89B4FA;font-style: italic;"> main</span><span>() {</span></span>
+<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;" ><code data-lang="gleam"><span class="giallo-l"><span style="color: #CBA6F7;">fn</span><span style="color: #89B4FA;font-style: italic;"> main</span><span>() {</span></span>
 <span class="giallo-l"><span style="color: #CBA6F7;">  assert</span><span style="color: #FAB387;"> 5</span><span style="color: #94E2D5;"> ==</span><span> { </span><span style="color: #FAB387;">1</span><span style="color: #94E2D5;"> |&gt;</span><span> add_one </span><span style="color: #94E2D5;">|&gt;</span><span> add_three }</span></span>
 <span class="giallo-l"><span>}</span></span></code></pre>
 <p>I feel like they also made a couple design decisions in a pythonic manner. For example, in the code above, you can see that to specify and clarify order of operations, instead of using parentheses it uses curly braces. This is because like rust, gleam is an expression based language, and therefore, code blocks return values without having to manually insert a return statement. It may seem like this is just trying to be different just to be different, but I really like this, and is just an interesting consequence of being expression based, and it removes unnecessary options to do functionally the same thing. In fact, you can do this in rust(another expression based language) as well!</p>
-<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;"><code data-lang="rust"><span class="giallo-l"><span style="color: #CBA6F7;">fn</span><span style="color: #89B4FA;font-style: italic;"> main</span><span style="color: #9399B2;">() {</span></span>
+<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;" ><code data-lang="rust"><span class="giallo-l"><span style="color: #CBA6F7;">fn</span><span style="color: #89B4FA;font-style: italic;"> main</span><span style="color: #9399B2;">() {</span></span>
 <span class="giallo-l"><span style="color: #CBA6F7;">  let</span><span> x</span><span style="color: #94E2D5;"> =</span><span style="color: #FAB387;"> 3</span><span style="color: #94E2D5;"> *</span><span style="color: #9399B2;"> {</span><span style="color: #FAB387;"> 2</span><span style="color: #94E2D5;"> +</span><span style="color: #FAB387;"> 3</span><span style="color: #9399B2;"> };</span></span>
 <span class="giallo-l"><span style="color: #89B4FA;font-style: italic;">  assert_eq!</span><span style="color: #9399B2;">(</span><span>x</span><span style="color: #9399B2;">,</span><span style="color: #FAB387;"> 15</span><span style="color: #9399B2;">);</span></span>
 <span class="giallo-l"><span style="color: #9399B2;">}</span></span></code></pre>
 <p>Now, back to the story. So I was having a bunch of stupid problems with the airport wifi, and my phone’s hotspot was bugging out as well, so I was completely offline for like 5 hrs, even before I got on the flight. (this was also kinda because my flight got delayed by 4 hrs, because they switched the plane we were going to be taking to a different one.) So during that time, I started to try to see what I could get done with the language. Gleam’s package manager/build tool/whatever cli is really nice, and it caches all the data of dependencies added to the project previously. So, basically what I did was before I left home, I added a bunch of packages that I saw were pretty commonly used in the community, and a web framework. So what I did while off the internet was just tinker around with the language and the libraries, trying to figure out what to do based on LSP Hover tips and examples. I wanted to figure out how to do argument parsing and a simple web application. For the argument parsing thing, I kinda just messed around with the argv library, and never actually tried out glint, the more full featured argument parser. The entire argv library is basically just a single function, <code>argv.load()</code>, that returns a list of strings, which are the arguments to the program. But this really beautifully showcases some of the power of gleam’s pattern matching:</p>
-<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;"><code data-lang="gleam"><span class="giallo-l"><span style="color: #CBA6F7;">pub fn</span><span style="color: #89B4FA;font-style: italic;"> main</span><span>() {</span></span>
+<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;" ><code data-lang="gleam"><span class="giallo-l"><span style="color: #CBA6F7;">pub fn</span><span style="color: #89B4FA;font-style: italic;"> main</span><span>() {</span></span>
 <span class="giallo-l"><span style="color: #CBA6F7;">  let</span><span style="color: #EBA0AC;font-style: italic;"> args: </span><span style="color: #F9E2AF;font-style: italic;">List</span><span>(</span><span style="color: #F9E2AF;font-style: italic;">String</span><span>) </span><span style="color: #94E2D5;">=</span><span> argv.</span><span style="color: #89B4FA;font-style: italic;">load</span><span>().arguments</span></span>
 <span class="giallo-l"><span style="color: #CBA6F7;">  case</span><span> args {</span></span>
 <span class="giallo-l"><span>    [</span><span style="color: #A6E3A1;">&quot;greet&quot;</span><span>, name] </span><span style="color: #94E2D5;">-&gt;</span><span> io.</span><span style="color: #89B4FA;font-style: italic;">println</span><span>(</span><span style="color: #A6E3A1;">&quot;hello &quot;</span><span style="color: #94E2D5;"> &lt;&gt;</span><span> name </span><span style="color: #94E2D5;">&lt;&gt;</span><span style="color: #A6E3A1;"> &quot;!&quot;</span><span>)</span></span>
@@ -59,7 +59,7 @@
 <span class="giallo-l"><span>}</span></span></code></pre>
 <p>I think that this is probably my favorite way to do simple command line argument parsing, even if it isn’t the most effective or feature complete. I guess if you want to do that, there is the glint library that I mentioned previously, but I haven’t really got around to exploring that yet.</p>
 <p>The second part of my little adventure was trying to make a little web app in the programming language. I ended up learning about an actual frontend framework that uses the fact that the language can compile to Javascript (lustre), but I already had hacked together a simple html/css/js frontend by that point. The finished project is at <a rel="external" href="https://files.taranathan.com">files.taranathan.com</a>, so you guys can check out what it ended up like there. (Side note: During the process, I ended up moving a lot of the things I was hosting on my web server from apache2 to Caddy, and it was really interesting! I think caddy is really cool, and it is sooooo much simpler to configure for the really simple things I am doing. I basically just host a wordpress site, run a gitweb site(cgi), run my site(just static hosting), and a couple of reverse proxies to expose my web-related projects. All I had to do was recompile caddy from source with a module for cgi.) So, if you went to the link, you would see that it is just a really simple file hosting/sharing site. The whole page is basically just a form asking for a file, a file name, and a password(I might give it to you if you ask really nicely \(°^°)/). So this is basically the entry point of the web server. The argument <code>file_path</code> is the path to where to store and serve the files from, and <code>passwords</code> is just a list of the valid passwords(i know, not very secure).</p>
-<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;"><code data-lang="gleam"><span class="giallo-l"><span style="color: #CBA6F7;">fn</span><span style="color: #89B4FA;font-style: italic;"> web</span><span>(</span><span style="color: #EBA0AC;font-style: italic;">file_path: </span><span style="color: #F9E2AF;font-style: italic;">String</span><span>, </span><span style="color: #EBA0AC;font-style: italic;">passwords: </span><span style="color: #F9E2AF;font-style: italic;">List</span><span>(</span><span style="color: #F9E2AF;font-style: italic;">String</span><span>)) </span><span style="color: #94E2D5;">-&gt;</span><span style="color: #F9E2AF;font-style: italic;"> Nil</span><span> {</span></span>
+<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;" ><code data-lang="gleam"><span class="giallo-l"><span style="color: #CBA6F7;">fn</span><span style="color: #89B4FA;font-style: italic;"> web</span><span>(</span><span style="color: #EBA0AC;font-style: italic;">file_path: </span><span style="color: #F9E2AF;font-style: italic;">String</span><span>, </span><span style="color: #EBA0AC;font-style: italic;">passwords: </span><span style="color: #F9E2AF;font-style: italic;">List</span><span>(</span><span style="color: #F9E2AF;font-style: italic;">String</span><span>)) </span><span style="color: #94E2D5;">-&gt;</span><span style="color: #F9E2AF;font-style: italic;"> Nil</span><span> {</span></span>
 <span class="giallo-l"><span>  wisp.</span><span style="color: #89B4FA;font-style: italic;">configure_logger</span><span>()</span></span>
 <span class="giallo-l"></span>
 <span class="giallo-l"><span style="color: #CBA6F7;">  let</span><span> secret_key_base </span><span style="color: #94E2D5;">=</span></span>
 <span class="giallo-l"><span>  process.</span><span style="color: #89B4FA;font-style: italic;">sleep_forever</span><span>()</span></span>
 <span class="giallo-l"><span>}</span></span></code></pre>
 <p>The router module is mine, and I’ll talk about it later. This might look pretty wierd to you, if you come from an imperative or OOP background, so I’ll go through it line by line. First we configure the logger, and then generate a <code>secret_key_base</code> either from an env variable or a random string. Then, we get to the <code>let assert Ok(_) = ...</code>. This basically means that the result of the expression in front of it is of the <code>result</code> type/enum, and it must be of the Ok variant, and we do not care about what is inside of the <code>Ok</code>. Another thing that might be confusing is the <code>router.handle_request(_, file_path, passwords)</code>. As I wrote about above, this is an example of partial function application. The actual function signature of router.handle_request is:</p>
-<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;"><code data-lang="gleam"><span class="giallo-l"><span style="color: #CBA6F7;">pub fn</span><span style="color: #89B4FA;font-style: italic;"> handle_request</span><span>(</span></span>
+<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;" ><code data-lang="gleam"><span class="giallo-l"><span style="color: #CBA6F7;">pub fn</span><span style="color: #89B4FA;font-style: italic;"> handle_request</span><span>(</span></span>
 <span class="giallo-l"><span style="color: #EBA0AC;font-style: italic;">  req: </span><span>wisp.</span><span style="color: #F9E2AF;font-style: italic;">Request</span><span>,</span></span>
 <span class="giallo-l"><span style="color: #EBA0AC;font-style: italic;">  file_path: </span><span style="color: #F9E2AF;font-style: italic;">String</span><span>,</span></span>
 <span class="giallo-l"><span style="color: #EBA0AC;font-style: italic;">  passwords: </span><span style="color: #F9E2AF;font-style: italic;">List</span><span>(</span><span style="color: #F9E2AF;font-style: italic;">String</span><span>),</span></span>
 <span class="giallo-l"><span>) </span><span style="color: #94E2D5;">-&gt;</span><span> wisp.</span><span style="color: #F9E2AF;font-style: italic;">Response</span><span> {</span></span></code></pre>
 <p>So what we are doing here is we are basically filling in <code>file_path</code> and <code>passwords</code> and changing the function signature into <code>fn(wisp.Request) -&gt; wisp.Response</code>. And then after that, we just pipe it into a couple of builder functions and then start it. After starting it, we tell the main process to sleep forever, because <code>mist.start</code> starts the process on another thread.</p>
 <p>Now lets take a look at the main route handler function:</p>
-<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;"><code data-lang="gleam"><span class="giallo-l"><span style="color: #CBA6F7;">pub fn</span><span style="color: #89B4FA;font-style: italic;"> handle_request</span><span>(</span></span>
+<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;" ><code data-lang="gleam"><span class="giallo-l"><span style="color: #CBA6F7;">pub fn</span><span style="color: #89B4FA;font-style: italic;"> handle_request</span><span>(</span></span>
 <span class="giallo-l"><span style="color: #EBA0AC;font-style: italic;">  req: </span><span>wisp.</span><span style="color: #F9E2AF;font-style: italic;">Request</span><span>,</span></span>
 <span class="giallo-l"><span style="color: #EBA0AC;font-style: italic;">  file_path: </span><span style="color: #F9E2AF;font-style: italic;">String</span><span>,</span></span>
 <span class="giallo-l"><span style="color: #EBA0AC;font-style: italic;">  passwords: </span><span style="color: #F9E2AF;font-style: italic;">List</span><span>(</span><span style="color: #F9E2AF;font-style: italic;">String</span><span>),</span></span>
 <span class="giallo-l"><span>  }</span></span>
 <span class="giallo-l"><span>}</span></span></code></pre>
 <p>So, the first line basically just sets up some basic middleware stuff. The use statement in gleam is pretty wierd and hard to wrap your head around, but it really is just some syntax sugar. For example, if we just removed the use statement from our function, it would look like this:</p>
-<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;"><code data-lang="gleam"><span class="giallo-l"><span style="color: #CBA6F7;">pub fn</span><span style="color: #89B4FA;font-style: italic;"> handle_request</span><span>(</span></span>
+<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;" ><code data-lang="gleam"><span class="giallo-l"><span style="color: #CBA6F7;">pub fn</span><span style="color: #89B4FA;font-style: italic;"> handle_request</span><span>(</span></span>
 <span class="giallo-l"><span style="color: #EBA0AC;font-style: italic;">  req: </span><span>wisp.</span><span style="color: #F9E2AF;font-style: italic;">Request</span><span>,</span></span>
 <span class="giallo-l"><span style="color: #EBA0AC;font-style: italic;">  file_path: </span><span style="color: #F9E2AF;font-style: italic;">String</span><span>,</span></span>
 <span class="giallo-l"><span style="color: #EBA0AC;font-style: italic;">  passwords: </span><span style="color: #F9E2AF;font-style: italic;">List</span><span>(</span><span style="color: #F9E2AF;font-style: italic;">String</span><span>),</span></span>
index 5a530d478e207b834192f4f4972d3001d74a3ac2..0ee3a6d5979d47cd6840c0f5882f19e9e1cacb39 100644 (file)
   <ul class="post-list">
     
       <li class="post-list-item">
-        <a href="https://taranathan.com/blog/extras/">extra photos from germany</a>
+        <a href="https://taranathan.com/blog/germany/">germany</a>
       <p class="subtitle""> — 2026-07-24</p>
       
     </li>
   
       <li class="post-list-item">
-        <a href="https://taranathan.com/blog/germany/">germany</a>
+        <a href="https://taranathan.com/blog/extras/">extra photos from germany</a>
       <p class="subtitle""> — 2026-07-24</p>
       
+    </li>
+  
+      <li class="post-list-item">
+        <a href="https://taranathan.com/blog/pipes/">pipes</a>
+      <p class="subtitle""> — 2026-06-22</p>
+      
     </li>
   
       <li class="post-list-item">
diff --git a/public/blog/pipes/index.html b/public/blog/pipes/index.html
new file mode 100644 (file)
index 0000000..cbf1960
--- /dev/null
@@ -0,0 +1,94 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+  <meta charset="utf-8">
+  <title>pipes</title>
+  <link rel="icon" type="image/x-icon" href="https://taranathan.com/favicon.ico">
+  <link rel="stylesheet" href="https://taranathan.com/styles.css">
+</head>
+
+<body>
+  <div class="container">
+    <div class="kaomoji-sidebar kaomoji-left">
+      <div class="scroll-text" id="kaomoji-left"></div>
+    </div>
+
+    <main class="content">
+      <header class="header">
+        <h1 href="/">My Blog</h1>
+        <nav class="nav">
+          <a href="/">Home</a>
+          <a href="/blog">Blog</a>
+          <a href="/miniblog">Miniblog</a>
+          <a href="/boo" target="_blank">Fun</a>
+        </nav>
+      </header>
+
+      <section class="content-body">
+        
+  <article class="post">
+    <h1 class="title">pipes</h1>
+    <p class="subtitle"><strong>2026-06-22</strong></p>
+    <div class="post-content"><p>Huh. I was just thinking about how cool a pipe operator would be in rust, and about method-chaining when I realized that they are both kind of the same thing! For example, look at these rust and gleam (a language with a very similar syntax):</p>
+<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;" ><code data-lang="rust"><span class="giallo-l"><span style="color: #9399B2;font-style: italic;">//rust</span></span>
+<span class="giallo-l"><span style="color: #CBA6F7;">let</span><span> result</span><span style="color: #94E2D5;">:</span><span style="color: #F9E2AF;font-style: italic;"> Result</span><span style="color: #89DCEB;">&lt;</span><span style="color: #CBA6F7;">i32</span><span style="color: #89DCEB;">&gt;</span><span style="color: #94E2D5;"> =</span><span style="color: #89B4FA;font-style: italic;"> fallible_operation</span><span style="color: #9399B2;">();</span></span>
+<span class="giallo-l"><span style="color: #CBA6F7;">let</span><span> output</span><span style="color: #94E2D5;"> =</span><span> result</span></span>
+<span class="giallo-l"><span style="color: #94E2D5;">  .</span><span style="color: #89B4FA;font-style: italic;">map</span><span style="color: #9399B2;">(</span><span>add_one</span><span style="color: #9399B2;">)</span></span>
+<span class="giallo-l"><span style="color: #94E2D5;">  .</span><span style="color: #89B4FA;font-style: italic;">map</span><span style="color: #9399B2;">(</span><span>add_one</span><span style="color: #9399B2;">)</span></span>
+<span class="giallo-l"><span style="color: #94E2D5;">  .</span><span style="color: #89B4FA;font-style: italic;">map</span><span style="color: #9399B2;">(</span><span>add_one</span><span style="color: #9399B2;">)</span></span>
+<span class="giallo-l"><span style="color: #94E2D5;">  .</span><span style="color: #89B4FA;font-style: italic;">unwrap_or</span><span style="color: #9399B2;">(</span><span style="color: #FAB387;">0</span><span style="color: #9399B2;">);</span></span></code></pre><br>
+<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;" ><code data-lang="gleam"><span class="giallo-l"><span style="color: #9399B2;font-style: italic;">//gleam</span></span>
+<span class="giallo-l"><span style="color: #CBA6F7;">let</span><span style="color: #EBA0AC;font-style: italic;"> result: </span><span style="color: #F9E2AF;font-style: italic;">Result</span><span>(</span><span style="color: #F9E2AF;font-style: italic;">Int</span><span>) </span><span style="color: #94E2D5;">=</span><span style="color: #89B4FA;font-style: italic;"> fallible_operation</span><span>()</span></span>
+<span class="giallo-l"><span style="color: #CBA6F7;">let</span><span> output </span><span style="color: #94E2D5;">=</span><span> result</span></span>
+<span class="giallo-l"><span style="color: #94E2D5;">  |&gt;</span><span> result.</span><span style="color: #89B4FA;font-style: italic;">map</span><span>(add_one)</span></span>
+<span class="giallo-l"><span style="color: #94E2D5;">  |&gt;</span><span> result.</span><span style="color: #89B4FA;font-style: italic;">map</span><span>(add_one)</span></span>
+<span class="giallo-l"><span style="color: #94E2D5;">  |&gt;</span><span> result.</span><span style="color: #89B4FA;font-style: italic;">map</span><span>(add_one)</span></span>
+<span class="giallo-l"><span style="color: #94E2D5;">  |&gt;</span><span> result.</span><span style="color: #89B4FA;font-style: italic;">unwrap</span><span>(</span><span style="color: #FAB387;">0</span><span>)</span></span></code></pre>
+<p>When they are formatted this way, don’t they look <em>pretttty</em> similar? That’s because, they are, by definition, the exact same thing. If you look into the function signatures behind any <code>impl</code> method/function in rust, they all start with an <code>&amp;self</code> or some variation because the dot notation is actually just syntax sugar. If I wanted to write out the rust example the long way, I could’ve done it like this:</p>
+<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;" ><code data-lang="rust"><span class="giallo-l"><span style="color: #9399B2;font-style: italic;">// the type of std::result::unwrap_or is fn(self, F) -&gt; Result&lt;U, E&gt;,</span></span>
+<span class="giallo-l"><span style="color: #9399B2;font-style: italic;">// but in dot notation the first argument is omitted, like in a pipe operator</span></span>
+<span class="giallo-l"></span>
+<span class="giallo-l"><span style="color: #CBA6F7;">let</span><span> result</span><span style="color: #94E2D5;">:</span><span style="color: #F9E2AF;font-style: italic;"> Result</span><span style="color: #89DCEB;">&lt;</span><span style="color: #CBA6F7;">i32</span><span style="color: #89DCEB;">&gt;</span><span style="color: #94E2D5;"> =</span><span style="color: #89B4FA;font-style: italic;"> fallible_operation</span><span style="color: #9399B2;">();</span></span>
+<span class="giallo-l"><span style="color: #CBA6F7;">let</span><span> output</span><span style="color: #94E2D5;"> =</span><span style="color: #F9E2AF;"> std</span><span style="color: #94E2D5;">::</span><span style="color: #F9E2AF;">result</span><span style="color: #94E2D5;">::</span><span style="color: #F9E2AF;font-style: italic;">Result</span><span style="color: #94E2D5;">::</span><span style="color: #89B4FA;font-style: italic;">unwrap_or</span><span style="color: #9399B2;">(</span></span>
+<span class="giallo-l"><span style="color: #F9E2AF;">  std</span><span style="color: #94E2D5;">::</span><span style="color: #F9E2AF;">result</span><span style="color: #94E2D5;">::</span><span style="color: #F9E2AF;">Result</span><span style="color: #94E2D5;">::</span><span style="color: #89B4FA;font-style: italic;">map</span><span style="color: #9399B2;">(</span></span>
+<span class="giallo-l"><span style="color: #F9E2AF;">  std</span><span style="color: #94E2D5;">::</span><span style="color: #F9E2AF;">result</span><span style="color: #94E2D5;">::</span><span style="color: #F9E2AF;">Result</span><span style="color: #94E2D5;">::</span><span style="color: #89B4FA;font-style: italic;">map</span><span style="color: #9399B2;">(</span></span>
+<span class="giallo-l"><span style="color: #F9E2AF;">  std</span><span style="color: #94E2D5;">::</span><span style="color: #F9E2AF;">result</span><span style="color: #94E2D5;">::</span><span style="color: #F9E2AF;">Result</span><span style="color: #94E2D5;">::</span><span style="color: #89B4FA;font-style: italic;">map</span><span style="color: #9399B2;">(</span><span style="color: #94E2D5;">&amp;</span><span>result</span><span style="color: #9399B2;">,</span><span> add_one</span><span style="color: #9399B2;">),</span><span> add_one</span><span style="color: #9399B2;">),</span><span> add_one</span><span style="color: #9399B2;">),</span></span>
+<span class="giallo-l"><span style="color: #FAB387;">  0</span><span style="color: #9399B2;">);</span></span></code></pre>
+<p>And the pipe operator in so many functional languages also serves the same purpose: as syntax sugar. Anyways, I just found this kind of neat, and my guess as to a little bit about why there isn’t a pipe operator in rust yet, despite taking so much heavy influence from functional languages like OCaml.</p>
+</div>
+  </article>
+
+      </section>
+    </main>
+
+    <div class="kaomoji-sidebar kaomoji-right">
+      <div class="scroll-text" id="kaomoji-right"></div>
+    </div>
+  </div>
+
+  <script>
+    // Smooth scrolling for internal links
+    document.querySelectorAll('nav a').forEach(anchor => {
+      anchor.addEventListener('click', function (e) {
+        const href = this.getAttribute('href');
+        if (href && href.startsWith('#')) {
+          e.preventDefault();
+          document.querySelector(href).scrollIntoView({ behavior: 'smooth' });
+        }
+      });
+    });
+
+    // Fetch kaomoji text if available
+    fetch('https://taranathan.com/kaomoji.txt').then(r => { if (r.ok) return r.text(); }).then(data => {
+      if (data) {
+        const l = document.getElementById('kaomoji-left');
+        const rgt = document.getElementById('kaomoji-right');
+        if (l) l.textContent = data;
+        if (rgt) rgt.textContent = data;
+      }
+    }).catch(()=>{});
+  </script>
+</body>
+
+</html>
index 98e70a57f3b7821e083e6ac02cbdf27997dd02e7..db0a0d9762a1852de6f68f9ff5c250767df23463 100644 (file)
@@ -3,7 +3,7 @@
 
 <head>
   <meta charset="utf-8">
-  <title>Miniblog&#x2F;journal posts</title>
+  <title>Miniblog/journal posts</title>
   <link rel="icon" type="image/x-icon" href="https://taranathan.com/favicon.ico">
   <link rel="stylesheet" href="https://taranathan.com/styles.css">
 </head>
@@ -27,7 +27,7 @@
 
       <section class="content-body">
         
-  <h2 class="section-title">Miniblog&#x2F;journal posts</h2>
+  <h2 class="section-title">Miniblog/journal posts</h2>
   <ul class="post-list">
     
       <li class="post-list-item">
index 27fe4ebe25a87c7756a3852587344fc47c4109f5..292f5eb37a76379b4be4f4b32c5649161fb268e4 100644 (file)
     <h1 class="title">pipes</h1>
     <p class="subtitle"><strong>2026-06-22</strong></p>
     <div class="post-content"><p>Huh. I was just thinking about how cool a pipe operator would be in rust, and about method-chaining when I realized that they are both kind of the same thing! For example, look at these rust and gleam (a language with a very similar syntax):</p>
-<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;"><code data-lang="rust"><span class="giallo-l"><span style="color: #9399B2;font-style: italic;">//rust</span></span>
+<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;" ><code data-lang="rust"><span class="giallo-l"><span style="color: #9399B2;font-style: italic;">//rust</span></span>
 <span class="giallo-l"><span style="color: #CBA6F7;">let</span><span> result</span><span style="color: #94E2D5;">:</span><span style="color: #F9E2AF;font-style: italic;"> Result</span><span style="color: #89DCEB;">&lt;</span><span style="color: #CBA6F7;">i32</span><span style="color: #89DCEB;">&gt;</span><span style="color: #94E2D5;"> =</span><span style="color: #89B4FA;font-style: italic;"> fallible_operation</span><span style="color: #9399B2;">();</span></span>
 <span class="giallo-l"><span style="color: #CBA6F7;">let</span><span> output</span><span style="color: #94E2D5;"> =</span><span> result</span></span>
 <span class="giallo-l"><span style="color: #94E2D5;">  .</span><span style="color: #89B4FA;font-style: italic;">map</span><span style="color: #9399B2;">(</span><span>add_one</span><span style="color: #9399B2;">)</span></span>
 <span class="giallo-l"><span style="color: #94E2D5;">  .</span><span style="color: #89B4FA;font-style: italic;">map</span><span style="color: #9399B2;">(</span><span>add_one</span><span style="color: #9399B2;">)</span></span>
 <span class="giallo-l"><span style="color: #94E2D5;">  .</span><span style="color: #89B4FA;font-style: italic;">map</span><span style="color: #9399B2;">(</span><span>add_one</span><span style="color: #9399B2;">)</span></span>
 <span class="giallo-l"><span style="color: #94E2D5;">  .</span><span style="color: #89B4FA;font-style: italic;">unwrap_or</span><span style="color: #9399B2;">(</span><span style="color: #FAB387;">0</span><span style="color: #9399B2;">);</span></span></code></pre><br>
-<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;"><code data-lang="gleam"><span class="giallo-l"><span style="color: #9399B2;font-style: italic;">//gleam</span></span>
+<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;" ><code data-lang="gleam"><span class="giallo-l"><span style="color: #9399B2;font-style: italic;">//gleam</span></span>
 <span class="giallo-l"><span style="color: #CBA6F7;">let</span><span style="color: #EBA0AC;font-style: italic;"> result: </span><span style="color: #F9E2AF;font-style: italic;">Result</span><span>(</span><span style="color: #F9E2AF;font-style: italic;">Int</span><span>) </span><span style="color: #94E2D5;">=</span><span style="color: #89B4FA;font-style: italic;"> fallible_operation</span><span>()</span></span>
 <span class="giallo-l"><span style="color: #CBA6F7;">let</span><span> output </span><span style="color: #94E2D5;">=</span><span> result</span></span>
 <span class="giallo-l"><span style="color: #94E2D5;">  |&gt;</span><span> result.</span><span style="color: #89B4FA;font-style: italic;">map</span><span>(add_one)</span></span>
@@ -46,7 +46,7 @@
 <span class="giallo-l"><span style="color: #94E2D5;">  |&gt;</span><span> result.</span><span style="color: #89B4FA;font-style: italic;">map</span><span>(add_one)</span></span>
 <span class="giallo-l"><span style="color: #94E2D5;">  |&gt;</span><span> result.</span><span style="color: #89B4FA;font-style: italic;">unwrap</span><span>(</span><span style="color: #FAB387;">0</span><span>)</span></span></code></pre>
 <p>When they are formatted this way, don’t they look <em>pretttty</em> similar? That’s because, they are, by definition, the exact same thing. If you look into the function signatures behind any <code>impl</code> method/function in rust, they all start with an <code>&amp;self</code> or some variation because the dot notation is actually just syntax sugar. If I wanted to write out the rust example the long way, I could’ve done it like this:</p>
-<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;"><code data-lang="rust"><span class="giallo-l"><span style="color: #9399B2;font-style: italic;">// the type of std::result::unwrap_or is fn(self, F) -&gt; Result&lt;U, E&gt;,</span></span>
+<pre class="giallo" style="color: #CDD6F4; background-color: #1E1E2E;" ><code data-lang="rust"><span class="giallo-l"><span style="color: #9399B2;font-style: italic;">// the type of std::result::unwrap_or is fn(self, F) -&gt; Result&lt;U, E&gt;,</span></span>
 <span class="giallo-l"><span style="color: #9399B2;font-style: italic;">// but in dot notation the first argument is omitted, like in a pipe operator</span></span>
 <span class="giallo-l"></span>
 <span class="giallo-l"><span style="color: #CBA6F7;">let</span><span> result</span><span style="color: #94E2D5;">:</span><span style="color: #F9E2AF;font-style: italic;"> Result</span><span style="color: #89DCEB;">&lt;</span><span style="color: #CBA6F7;">i32</span><span style="color: #89DCEB;">&gt;</span><span style="color: #94E2D5;"> =</span><span style="color: #89B4FA;font-style: italic;"> fallible_operation</span><span style="color: #9399B2;">();</span></span>
index 0812086ff4c1d43aabbf78718ba3338867514fa1..3f3d310113a0ed7a5ec13f75c60992fe207dfe5b 100644 (file)
         <loc>https://taranathan.com/blog/gleam/</loc>
         <lastmod>2026-06-15</lastmod>
     </url>
+    <url>
+        <loc>https://taranathan.com/blog/pipes/</loc>
+        <lastmod>2026-06-22</lastmod>
+    </url>
     <url>
         <loc>https://taranathan.com/blog/second/</loc>
         <lastmod>2026-06-01</lastmod>
diff --git a/templates/main-page.html b/templates/main-page.html
deleted file mode 100644 (file)
index 775e502..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-{% extends "base.html" %}
-
-<h1>
-wassup
-</h1>