Skip to content

Back to the catalog

abhinavsarkar.net
atomEnglish

Posts on abhinavsarkar.net

abhinavsarkar.net · abhinavsarkar.net · English

Personal website and blog of Abhinav Sarkar.

atomfediverseindieweb

Open the feed

https://abhinavsarkar.net/posts/feed.atom

Last post
Oct 31, 2026
Posts in 24 h · 7 days · 30 days
0 · 0 · 1
Our last check
Answering
Served from
United States
Site title
Home
Text score
95,276
Format
atom
Community
fediverse, indieweb

Posts

What our queue read from this feed. Open one to read it here, or go to the site that published it.

  1. An LC-3 Disassembler in Haskell
    Oct 31, 2026 · original
    LC-3 assembly is an educational programming language. It is simple enough that complex programs can be written directly in it without needing a compiler, and thus it is often used in teaching assembly. An LC-3 textual assembly program is compiled to a binary object file by an assembler, and then executed by a virtual machine . Writing a virtual machine for LC-3 is a fun little exercise. However, in this post, we implement a disassembler for compiled LC-3 binaries back to textual assembly programs. This post was originally published on abhinavsarkar.net . Contents Introduction to LC-3 Problem in Disassembling LC-3 Setting Up Decoding Instructions Basic Disassembly Fixed-Point Cleanup Postprocessing Pretty-Printing Reading the Binary Finishing Up Conclusion Introduction to LC-3 # LC-3 has a simple instruction set with only 18 instructions. It works with eight 16-bit registers (numbered fro
  2. Fast Haskell Scripts on GitHub Actions
    Aug 10, 2026 · original
    Magix is a neat tool that lets us run Haskell programs as scripts 1 . We put a shebang on top mentioning Magix, list the Haskell packages we need, and ./script.hs just works. This post is about running such a script fast(er) on GitHub Actions . This post was originally published on abhinavsarkar.net . Contents The Setup The Problem The Idea The Bundle The GitHub Actions Workflow The Payoff The Conclusion The Setup # As our example, we’ll take the static site generator (SSG) I wrote some time ago: BlogShake . It is written as a single Haskell file. It uses Shake to build the website, Pandoc to render posts, and Mustache for templates. The script starts with these Magix directives 2 : #!/usr/bin/env magix #!magix haskell #!haskellPackages mustache pandoc shake feed yaml #!ghcFlags -threaded -O2 Running the script is as simple as: ./blog.hs Magix compiles the script into an executable and r
  3. Nix for Haskell: Static Builds
    Jun 18, 2026 · original
    In the previous post , we learned how to get started with managing and building a Haskell project with Nix . In this post, we learn how to easily create statically-linked executables for Haskell projects with Nix. This post was originally published on abhinavsarkar.net . This post is a part of the series: Nix for Haskell . Getting Started Static Builds 👈 Contents Static Builds Enabling Static Builds in GHC Configuring the Application Rooting Static Build Dependencies Finale Bonus: Building a Docker Image Conclusion I recommend going through the previous post , because we are going to start off from where we left last time (ignoring the bonus sections). This is how our project’s directory tree looks at this point: . |— app | |— Main.hs |— ftr.cabal |— nix | |— nixpkgs.nix | |— sources.json | |— sources.nix |— package.nix |— shell.nix Main.hs is the default generated main file that prints
  4. Implementing Co, a Small Language With Coroutines #5: Adding Sleep
    Jan 16, 2026 · original
    In the previous post , we added channels to Co , the small language we are implementing in this series of posts. In this post, we add the sleep primitive to it, enabling time-based coroutine scheduling. We then use sleep to build a simulation of digital logic circuits. This post was originally published on abhinavsarkar.net . This post is a part of the series: Implementing Co, a Small Language With Coroutines . The Parser The Interpreter Adding Coroutines Adding Channels Adding Sleep 👈 Contents Introduction Adding Sleep Delayed Coroutines Queuing Coroutines Implementing Sleep Sleep in Action Sleep Sort JavaScript-like Timeouts and Intervals Bonus Round: Digital Circuit Simulation Conjuring Lists Wires Logic Gates Adders Ripple-carry Adder Conclusion Introduction # Sleep is a commonly used operation in concurrent programs. It pauses the execution of the current Thread of Computation (ToC
  5. How I use Jujutsu
    Jan 10, 2026 · original
    About three months ago I started using Jujutsu (JJ), a new Version Control System , for my personal projects. It took me a while to get used to it after more than a decade of using Git , but now I’m quite comfortable with it. Working with Jujutsu requires a shift from the mental model of Git. However, it is not as daunting as it may seem on the first day. This post was originally published on abhinavsarkar.net . Looking back, I don’t actually use all the fancy things JJ provides, and you may not need to either. In this post I list my most used JJ commands and how I use them. It is not meant to be a tutorial, or even a comprehensive list, but it should be enough to get you started. This post assumes that the reader knows how to use Git. Contents Starting Up jj git init jj git clone jj config Creating Changes jj new jj describe jj commit jj status Modifying Changes jj edit jj squash jj spl
  6. A Fast Bytecode VM for Arithmetic: The Virtual Machine
    Oct 21, 2025 · original
    In this series of posts, we write a fast bytecode compiler and a virtual machine for arithmetic in Haskell. We explore the following topics: Parsing arithmetic expressions to Abstract Syntax Trees (ASTs). Unit testing for our parser. Interpreting ASTs. Compiling ASTs to bytecode. Disassembling and decompiling bytecode. Unit testing for our compiler. Property-based testing for our compiler. Efficiently executing bytecode in a virtual machine (VM). Unit testing and property-based testing for our VM . Benchmarking our code to see how the different passes perform. All the while keeping an eye on performance. In this final post, we write the virtual machine that executes our bytecode, and benchmark it. This post was originally published on abhinavsarkar.net . This post is a part of the series: A Fast Bytecode VM for Arithmetic . The Parser The Compiler The Virtual Machine 👈 Contents Introduc
  7. A Fast Bytecode VM for Arithmetic: The Compiler
    Aug 24, 2025 · original
    In this series of posts, we write a fast bytecode compiler and a virtual machine for arithmetic in Haskell. We explore the following topics: Parsing arithmetic expressions to Abstract Syntax Trees (ASTs). Unit testing for our parser. Interpreting ASTs. Compiling ASTs to bytecode. Disassembling and decompiling bytecode. Unit testing for our compiler. Property-based testing for our compiler. Efficiently executing bytecode in a virtual machine (VM). Unit testing and property-based testing for our VM . Benchmarking our code to see how the different passes perform. All the while keeping an eye on performance. In this post, we write the compiler for our AST to bytecode, and a decompiler for the bytecode. This post was originally published on abhinavsarkar.net . This post is a part of the series: A Fast Bytecode VM for Arithmetic . The Parser The Compiler 👈 The Virtual Machine Contents Introdu
  8. A Fast Bytecode VM for Arithmetic: The Parser
    Aug 2, 2025 · original
    In this series of posts, we write a fast bytecode compiler and a virtual machine for arithmetic in Haskell. We explore the following topics: Parsing arithmetic expressions to Abstract Syntax Trees (ASTs). Unit testing for our parser. Interpreting ASTs. Compiling ASTs to bytecode. Disassembling and decompiling bytecode. Unit testing for our compiler. Property-based testing for our compiler. Efficiently executing bytecode in a virtual machine (VM). Unit testing and property-based testing for our VM . Benchmarking our code to see how the different passes perform. All the while keeping an eye on performance. In this post, we write the parser for our expression language to an AST , and an AST interpreter. This post was originally published on abhinavsarkar.net . This post is a part of the series: A Fast Bytecode VM for Arithmetic . The Parser 👈 The Compiler The Virtual Machine Contents Intro
  9. Interpreting Brainfuck in Haskell
    Jan 19, 2025 · original
    Writing an interpreter for Brainfuck is almost a rite of passage for any programming language implementer, and it’s my turn now. In this post, we’ll write not one but four Brainfuck interpreters in Haskell. Let’s go! This post was originally published on abhinavsarkar.net . Contents Introduction Setup String Interpreter AST Interpreter Bytecode Interpreter Optimizing Bytecode Interpreter Comparison Introduction # Brainfuck (henceforth BF) is the most famous of esoteric programming languages. Its fame lies in the fact that it is extremely minimalist, with only eight instructions, and very easy to implement. Yet, it is Turing-complete and as capable as any other programming language 1 . Writing an interpreter for BF is a fun exercise, and so there are hundreds, maybe even thousands of them. Since BF is very verbose, optimizing BF interpreters is almost a sport, with people posting benchmar
  10. Solving Advent of Code “Seating System” with Comonads and Stencils
    Jan 5, 2025 · original
    In this post, we solve the Advent of Code 2020 “Seating System” challenge in Haskell using comonads and stencils. This post was originally published on abhinavsarkar.net . This post is a part of the series: Solving Advent of Code . “Handy Haversacks” in Type-level Haskell “No Space Left On Device” with Parsers, Zippers and Interpreters “Rock-Paper-Scissors” in Type-level Haskell “Aplenty” by Compiling “Seating System” with Comonads and Stencils 👈 Contents The Challenge The Cellular Automaton The Solution The Zipper The Comonad The Array The Stencil The Challenge # Here’s a quick summary of the challenge: The seat layout fits on a grid. Each position is either floor ( . ), an empty seat ( L ), or an occupied seat ( # ). For example, the initial seat layout might look like this: L.LL.LL.LL LLLLLLL.LL L.L.L..L.. LLLL.LL.LL L.LL.LL.LL L.LLLLL.LL ..L.L..... LLLLLLLLLL L.LLLLLL.L L.LLLLL.LL A
  11. Going REPLing with Haskeline
    Oct 31, 2024 · original
    So you went ahead and created a new programming language, with an AST, a parser, and an interpreter. And now you hate how you have to write the programs in your new language in files to run them? You need a REPL ! In this post, we’ll create a shiny REPL with lots of nice features using the Haskeline library to go along with your new PL that you implemented in Haskell. This post was originally published on abhinavsarkar.net . Contents The Demo Dawn of a New Language A REPL of Our Own State and Settings REPLing Down the Prompt Reading the Input Evaluating the Input Doing the Completions Conclusion The Demo # First a short demo: That is a pretty good REPL, isn’t it? You can even try it online 1 , running entirely in your browser. Dawn of a New Language # Let’s assume that we have created a new small Lisp 2 , just large enough to be able to conveniently write and run the Fibonacci function t
  12. Nix for Haskell: Getting Started
    Aug 29, 2024 · original
    So, you’ve heard of the new hotness that is Nix , for creating reproducible and isolated development environments, and want to use it for your new Haskell project? But you are unclear about how to get started? Then this is the guide you are looking for. This post was originally published on abhinavsarkar.net . This post is a part of the series: Nix for Haskell . Getting Started 👈 Static Builds Contents Nix for Haskell Shelling Out Bonus Round: Flakes Conclusion Nix is notoriously hard to get started with. If you are familiar with Haskell, you may have an easier time learning the Nix language , but it is still difficult to figure out the various toolchains and library functions needed to put your knowledge of the Nix language to use. There are some frameworks for setting up Haskell projects with Nix, but again, they are hard to understand because of their large feature scopes. So, in thi
  13. Solving Advent of Code “Aplenty” by Compiling
    Apr 7, 2024 · original
    Every year I try to solve some problems from the Advent of Code (AoC) competition in a not straightforward way . Let’s solve the part one of the day 19 problem Aplenty by compiling the problem input to an executable file. This post was originally published on abhinavsarkar.net . This post is a part of the series: Solving Advent of Code . “Handy Haversacks” in Type-level Haskell “No Space Left On Device” with Parsers, Zippers and Interpreters “Rock-Paper-Scissors” in Type-level Haskell “Aplenty” by Compiling 👈 “Seating System” with Comonads and Stencils Contents The Problem The Parser The Interpreter The Control-flow Graph The Compiler The Compiler Output The Bonus: Optimizations The Conclusion The Problem # What the problem presents as input is essentially a program. Here is the example input: px{a2006:qkq,m2090:A,rfg} pv{a1716:R,A} lnx{m1548:A,A} rfg{s537:gd,x2440:R,A} qs{s3448:A,lnx}
  14. Implementing Co, a Small Language With Coroutines #4: Adding Channels
    Jun 3, 2023 · original
    In the previous post , we added coroutines to Co , the small language we are implementing in this series of posts. In this post, we add channels to it to be able to communicate between coroutines. This post was originally published on abhinavsarkar.net . This post is a part of the series: Implementing Co, a Small Language With Coroutines . The Parser The Interpreter Adding Coroutines Adding Channels 👈 Adding Sleep Contents Introduction Channel Design Channel Operations Adding Channels Wiring Channels Sending and Receiving Pubsub using Channels Bonus Round: Emulating Actors Introduction # With coroutines, we can now have multiple Threads of Computation (ToCs) in a Co program. However, right now these ToCs work completely independent of each other. Often in such concurrent systems, we need to communicate between these ToCs , for example, one coroutine may produce some data that other coro
  15. Implementing Co, a Small Language With Coroutines #3: Adding Coroutines
    Feb 11, 2023 · original
    In the previous post , we wrote the interpreter for basic features of Co , the small language we are building in this series of posts. In this post, we explore and implement what makes Co really interesting: support for lightweight concurrency using Coroutines. This post was originally published on abhinavsarkar.net . This post is a part of the series: Implementing Co, a Small Language With Coroutines . The Parser The Interpreter Adding Coroutines 👈 Adding Channels Adding Sleep In this and next two posts, we add support for the following features to the Co interpreter: yield statement to yield the current thread of computation (ToC). spawn statement to start a new ToC . First class channels with operators to send and receive values over them. sleep function to sleep the current ToC for a given number of milliseconds. Let’s Co ! Contents Coroutines Coroutines in Various Languages Impleme
  16. Writing a Static Site Generator Using Shake
    Dec 17, 2022 · original
    Static site generators (SSGs) are all rage these days as people realize that plain HTML websites are good enough for most cases. SSGs take raw data in various formats—often Markdown , JSON , and YAML —and process them to produce the static websites, which can then be hosted easily on any hosting provider, or on personal VPSes . In this post, we write a bespoke SSG using the Shake build system. This post was originally published on abhinavsarkar.net . Contents Introduction Build Systems Static Site Structure Main Build Targets Build Rules Utilities Building the Blog Shake Features Tips and Tricks Conclusion Introduction # In the beginning , people coded websites by hand, painstakingly writing the HTML tags and CSS styles (and JavaScript code, if they were into DHTML ). Many weblogs were crafted by the hands of passionate individuals, even before the word Blog came into being. Over time, t
  17. Solving Advent of Code “No Space Left On Device” with Parsers, Zippers and Interpreters
    Dec 9, 2022 · original
    In this post, we solve the Advent of Code 2022, “No Space Left On Device” challenge in Haskell using parsers, zippers and interpreters. This post was originally published on abhinavsarkar.net . This post is a part of the series: Solving Advent of Code . “Handy Haversacks” in Type-level Haskell “No Space Left On Device” with Parsers, Zippers and Interpreters 👈 “Rock-Paper-Scissors” in Type-level Haskell “Aplenty” by Compiling “Seating System” with Comonads and Stencils Contents The Challenge Setup Modeling the Filesystem Parsing the Browsing Session Navigating and Modifying the Filesystem Interpreting the Browsing Session Solving the Challenge Running the Program The Challenge # Here’s a quick recap of the challenge: You browse around the filesystem to assess the situation and save the resulting terminal output (your puzzle input). For example: $ cd / $ ls dir a 14848514 b.txt 8504156 c.
  18. Just, Nix Shell and Podman are a Killer Combo
    Oct 5, 2022 · original
    Let’s say, for some unclear reasons, you need to compile the “Hello World” C program using a variety of C compilers. #include stdio.h int main () { printf ( "Hello World" ); return 0 ; } hello.c Let’s also say that your dev machine is a MacBook, and some of these C compilers run only on Linux. Thanks to the advancements made in Nix, everything in this post is completely unnecessary now. Just setup a Linux builder on Macos by following this tutorial , and mark the Linux-only packages so in their Nix config using the system parameter for the nixpkgs config. Rest is taken care by Nix automatically. Let’s start with Clang . Clang is the default C compiler on macOS, and you probably have it already installed. Let that be the case, and you compile hello.c by running: clang -o hello-clang hello.c Well and good. But you don’t want to be typing all that every time you need to compile (your unusua
  19. Implementing Co, a Small Language With Coroutines #2: The Interpreter
    Sep 21, 2021 · original
    In the previous post , we wrote the parser for Co , the small language we are building in this series of posts. The previous post was all about the syntax of Co . In this post we dive into the semantics of Co , and write an interpreter for its basic features. This post was originally published on abhinavsarkar.net . This post is a part of the series: Implementing Co, a Small Language With Coroutines . The Parser The Interpreter 👈 Adding Coroutines Adding Channels Adding Sleep Contents Previously, on … Running a Program Runtime Values Environment Model of Evaluation Scopes Closures Early Returns The Interpreter Manipulating Environments Evaluating Expressions Executing Statements Evaluating Function Calls Interpreting a Program Previously, on … # Here’s a quick recap. The basic features of Co that we are aiming to implement in this post are: Dynamic and strong typing. Null, boolean, stri
  20. Implementing Co, a Small Language With Coroutines #1: The Parser
    Apr 24, 2021 · original
    Many major programming languages these days support some lightweight concurrency primitives. The most recent popular ones are Goroutines in Go , Coroutines in Kotlin and Async in Rust . Let’s explore some of these concepts in detail by implementing a programming language with support for coroutines and Go-style channels. This post was originally published on abhinavsarkar.net . This post is a part of the series: Implementing Co, a Small Language With Coroutines . The Parser 👈 The Interpreter Adding Coroutines Adding Channels Adding Sleep Contents Lightweight Concurrency Introducing Co The Co Interpreter The Co AST Expressions Statements Parsing Parsing Expressions Parsing Statements Lightweight Concurrency # Lightweight concurrency has been a popular topic among programmers and programming language designers alike in recent times. Many languages created in the last decade have support f

Found by rss-feed-index, which checks each feed once a month at most.

Same record as JSON: https://api.agentalog.com/api/feeds/fd_abhinavsarkar_net_a79c002a5022ee62. More from this site: abhinavsarkar.net in the Feeds tab.

Looking for something else?QuestionsContact