Parser combinators in Rust

I have been working on a side project in Rust recently and thought I would write up some of the interesting things I've encountered while building something substantial and learning Rust at the same time. Early in the project, I had a need to some strings into structured types. Coming from Haskell, my first thought was to use parser combinators; however, I was open to other options if there was something better or more conventional in the Rust ecosystem. It is probably worth a separate post to…

Releasing haggle-0.2

I just pushed a new release of haggle to Hackage today. The haggle library implements a number of different representations of graph data structures with different capability and efficiency tradeoffs. It is inspired by both fgl and boost::graph, with the goal of enabling users to choose the right graph representation for their needs, while avoiding the partial functions that are used in fgl. This release largely adds some instances contributed by users (including some Unbox instances). The one …

Introducing build-bom

TL;DR The build-bom tool makes it easy to obtain LLVM IR for C/C++ programs without requiring any modifications to build systems by using the low-level debugger primitive ptrace. This is something you may want if you build tools to analyze C/C++ programs. A typical use of build-bom looks like: ./configure build-bom generate-bitcode -- make build-bom extract-bitcode /path/to/binary --output binary.bc Background What is LLVM IR? LLVM IR is the intermediate representation of code used by LLV…

Avy Interactive

The excellent avy package for emacs provides an efficient mechanism for positioning the cursor in the current window. The avy workflow is: Active avy via one of several possible functions Type a few characters corresponding to the location on screen you want to navigate to Avy will highlight each occurrence of those characters with navigation hints Type the one or two letters corresponding to the desired destination Avy typically enables navigation to any position on screen in four or five ke…

Less Funny Type Errors Issue 2

This is part two of the presumably unending type errors series. The previous entry involved an amusing type error. This time the error is a bit less amusing: ghc: panic! (the 'impossible' happened) (GHC version 8.8.3 for x86_64-unknown-linux): exprToType Call stack: CallStack (from HasCallStack): callStackDoc, called at compiler/utils/Outputable.hs:1159:37 in ghc:Outputable pprPanic, called at compiler/coreSyn/CoreSyn.hs:1997:28 in ghc:CoreSyn Please …

Funny Type Errors Issue 1

I find that I run into a large number of what I would consider Funny Type Errors while using GHC. This is the first post in what will presumably be a long series of posts on the topic. Today I was working on trying to improve the performance of a codebase that uses a large number of the type system extensions provided by modern GHC including -XGADTs and -XTypeInType. Seeing strange type errors in this code is expected on a daily basis. However, the code I was working in today was not doing an…

Metablog 2019

Instead of writing about something productive, I am going to again write about writing. Or at least the infrastructure for writing. First, I decided to switch comments from Disqus to utteranc.es, which is a clever approach to hosting comments for statically-generated sites. For each post, the script creates a GitHub issue and adds each comment to the issue. There are no ads, and it is all around more civilized. Moreover, I appreciate the simplicity of the model. Not that I expect an excess…

Emacs Startup Optimization

Recently, I had the urge to optimize the startup time of my emacs configuration. I managed to reduce my startup time from three seconds to under half a second. It was a fun exercise even though I don't really start emacs that often. Even that minor reduction makes starting a new emacs instance (e.g., from mutt or in a terminal) much more pleasant. I could use the server functionality in emacs (along with emacsclient) to always connect to a single persistent instance, but I like the isolation…

Emacs and Terminal Pasting

Over the last few weeks, I've found myself having to copy and paste large chunks of text into emacs running in a terminal. This leads to some annoyance, as each character pasted triggers a keystroke. In particular, every newline triggers indentation via newline-and-indent. This is very annoying, as the indentation usually gets a bit messy and turns into an ugly staircase of text. Vim has a solution to this problem via a command :set paste, which turns off indentation while pasting. More gene…

Linux Messaging Clients

I recently found myself looking at Linux instant messaging clients again. Sometimes I feel like some kind of Luddite for still using a desktop instant messaging client, but I just cannot bring myself to use a web application. I have used pidgin for as long as I can remember, but I have been looking for an alternative with better support for primarily keyboard interaction. My biggest complaints about pidgin center around odd focus issues that sometimes seem to require a mouse to fix. Unfortuna…