It didn’t look like anyone had ever tried to answer the
 question ,
so I thought I would have a go. This post probably won’t be interesting to
folks already familiar with embeddings or linear algebra. It represents my
rough, non-expert understanding of the subject matter 
 
 Huh. What could it mean to subtract two words, and how
would you even do that? If we…
Haskell binaries can get quite large (think ~100MB), especially for projects
with many transitive dependencies. Here are two strategies that can help at
link time, the latter being more experimental. 
 I used the test-pandoc binary from pandoc on
GHC 9.2.5 below. This was nice because obviously it was easy to test if linking
broke anything (just run the tests). 
…
*This is a followup to this previous post 
where I play with GCC’s link-time optimization in GHC-compiled programs. I note there that this is
limited since it only works on sources compiled from C (crucially the RTS). Here I’ve compiled rough
notes doing the same thing with LLVM LTO, where I attempt to get true whole-program optimization
*cooking. 
 The goals were…
I wrote a little tool to graph the fine-grained timing logs produced by ghc
when the -v (verbose) flag is given. These logs to STDERR look like, e.g. 
 !!! Liberate case [Data.Binary.Class]: finished in 32.06 milliseconds, allocated 14.879 megabytes
!!! Simplifier [Data.Binary.Class]: finished in 873.97 milliseconds, allocated 563.867 megabytes
 
 The project is on GitHub…
I spent some time hacking GHC to use GCC’s link-time optimization ,
and wanted to share the results. The idea was to see whether we could get
performance gains or other interesting results from : 
 
 cross module inlining, e.g. between C libraries from base and the RTS 
 GCC build flags that can only be added later, like -march=native to tailor optimizations to our…
This is a diary-style post where I chronicle what I learn digging into a
digital guitar effects pedal for the first time. I’m not sure how useful or
interesting it will be to others. 
 
 I picked up an oddball modulation pedal from a “boutique” maker (being coy here)
and decided there were a bunch of things I could improve about it, so I thought
I’d…
I had an occasion to think about text-friendly binary encoding schemes for the
first time at work. The obvious choice is
 Base64 , but my immediate subsequent
thought was “there must be something much more efficient for our purposes”, and a quick google led
 here 
in which OP echos the same feeling: 
 
 It seems to me that we can greatly improve since on my…
With help from Reid Barton in questions here and
 here I discovered it’s pretty
easy to call assembly from GHC haskell with minimal overhead, so I cleaned up
an example of this technique and posted it here: 
 https://github.com/jberryman/almost-inline-asm-haskell-example 
 This is especially useful if you want to return multiple values from a foreign
procedure, where…
I just released a new Haskell library called unagi-bloomfilter that is up now
 on hackage . You can
install it with: 
 $ cabal install unagi-bloomfilter
 
 The library uses the bloom-1 variant from “Fast Bloom Filters and Their
Generalization” by Yan Qiao, et al. I’ll try to write more about it when I have
the time. Also I just gave a talk on things I…
I’ve just released version 1.0 of a haskell library for principled,
cross-platform & extensible hashing of types. It is available
 on hackage , and can be
installed with: 
 cabal install hashabler
 
 (see my initial announcement post 
which has some motivation and pretty pictures) 
 You can see the CHANGELOG 
but the main change is an implementation of…
I just started implementing SipHash in
 hashabler and wanted to share
a nice way I found to translate stateful bit-twiddling code in C (which makes
heavy use of bitwise assignment operators) to haskell. 
 I was working from the
 reference implementation .
As you can see statefulness and mutability are an implicit part of how the
algorithm is defined, as it modifies the…
I’ve just released the first version of a haskell library for principled,
cross-platform & extensible hashing of types, which includes an implementation
of the FNV-1a algorithm. It is available on hackage ,
and can be installed with: 
 cabal install hashabler
 
 hashabler is a rewrite of the hashable 
library by Milan Straka and Johan Tibell, having the following…
There’s a pervasive myth that Bryan O’Sullivan’s excellent haskell benchmarking
library criterion is only
useful for benchmarks that take some significant chunk of time (I’ve even heard
some people claim on the ms scale). In fact criterion is useful for almost
anything you’d want to benchmark. 
 At a high level criterion makes your benchmark the…
Today I released version 0.2 of unagi-chan , a haskell library implementing
fast and scalable FIFO queues with a nice and familiar API. It is
 available on hackage 
and you can install it with: 
 $ cabal install unagi-chan
 
 This version provides a bounded queue variant (and closes
 issue #1 !)
that has performance on par with the other variants in the library.…
I’ve been doing a lot of experimenting with concurrent operations in haskell
and in particular playing with and thinking about the design of concurrent
 FIFO queues .
These structures are difficult to make both efficient and correct,
due to the effects of contention on the parts of the structure tasked with
coordinating reads and writes from multiple threads. 
 These…
This is the first real release shapely-data , a haskell library
 up here on hackage 
for working with algebraic datatypes in a simple generic form made up of
haskell’s primitive product, sum and unit types: (,) , Either , and () . 
 You can install it with 
 cabal install shapely-data
 
 Motivation and examples 
 In order from most to least important to me,…
In this post 
Philip Nilsson describes an inspiring, principled approach to solving
a toy problem posed in a programming interview. I wanted to implement a
solution to a variant of the problem where we’d like to process a stream.
It was pretty easy to sketch a solution out on paper but Philip’s solution
was invaluable in testing and debugging my implementation. (See…
TypeFamilies is a GHC extension that lets you create formerly-impossible
abstractions in a very straightforward way. It took me several tries before
they clicked for me though, so this is the introduction to TypeFamilies that
I wish I had read first (although I just found Brent Yorgey’s , which would have done the trick). 
 I’m treating the subject very narrowly for…
After pouring 1.5 bottles of horrid caustic chemicals down the drain to no
avail, I found I was able to clear a tough clogged shower drain with just the
empty bottle: 
 
 pour kettle full of boiling water into drain 
 stuff overflow drain with plastic wrap (so that pressure is directed toward the clog, not out the top) 
 invert empty draino bottle placing mouth around…
Disclaimer: un-researched, under-educated, fast and loose hacking follows. 
 
 The other day I was thinking about counting in binary and how bits cascade when
incrementing a counter. 
 000
001
010
011
100
 
 I wondered: what if each bit flip was very “expensive”, for the hardware say?
Are there other methods we could use that woud result in a…
I just learned about GHC’s RebindableSyntax extension from
 chrisdoner’s thread on reddit 
and wanted to play around with scratching a couple itches I’ve had. In this
post I’ll illustrate using RebindableSyntax to allow us to use haskell’s
 do notation in a State-monad-like construction, in which our state type is
allowed to change (I’ve…
A couple posters for the
 Classical Revolution RVA events at
Balliceaux in November and December. Great programs both. 
 
 These both play with some photograms of found glasses I’d made prior. 

I’ve released a new library 
for writing sort of idiomatic-looking loops with delays in javascript. This was
motivated by this 
work in which I was implementing an algorithm/simulation;
I wanted the code to be readable as straighforward loops, but I needed
a delay for the visual portion. 
 Here is an example of its usage: 
 withDelay(1000).endingWith(other_stuff)…
My first linocut. Two-color stencil with Krylon fluorescent paint, under linocut
block-printed text and outline. Then I quickly painted highlights with a paint pen
on each. The adorable font “Leckerli” 
was designed by Gesine Todt . 
 
 Promotion for Richmond Symphony Orchestra players’ website, and fun party favor
for their show tonight at Balliceaux.
I’ve finally had a chance to look at how my new lens-based, power-packed,
minimal zipper library zippo 
looks when compiled, and initial results are pleasing! 
 For example, here is a silly zipper operation that increments the nodes
of a sort-of tree: 
 module Main where

import Control.Category((>>>))
import Data.Lens.Zipper
import…
simple-actors 
is my library for more structured concurrent programming based
on the Actor model .
It’s been a fun vehicle for exploring concurrent
semantics, and an opportunity to solve some tricky API design problems in
pretty clever ways. I want to present a handful of these problems, and the
solutions I came up with, below. 
 Short digression: I love…
I finished this new zipper library 
which you can get with a 
 cabal install zippo
 
 and fork it on github . 
 After working for a long time on pez ,
I wanted to try a zipper library that was also based on lenses, but where
heterogenous move up operations would be type-checked, as would a move up
past the “top” of the structure. 
 It looks as though…
I’ve finished a simulation-visualization of the very cool algorithm for
generating a
 Maximal Independant Set 
from “A Biological Solution to a Fundamental Distributed Computing Problem” by
Afek et al. (sorry I don’t have a link to the PDF, and respect you too much to
link you to a paywall). 
 You can play with it 
or check out the code on…
I recently needed to do some conversions/processing to a bunch of HTML files,
which contained html canvas 
images, so I needed a way of converting all the canvas elements on the page to
PNGs. 
 After a bit of research and tweaking, the following worked well enough for me: 
 {% gist 2561736 %} 
 Run it in your browser’s JS console on the page you want to process (we…
I just uploaded the first version of a lens library I’ve been working on, called
 yall . You can get it with a 
 cabal install yall
 
 or check it out on github . There will be a
Template Haskell library for automatically deriving lenses at some point in the
future. 
 I was motivated primarily by the desire for a lens that is acceptable for
 pez (existing libs…
I was just looking at the Monoid 
docs, when I found an instance that surprised me: Ordering . 
 Here is how it’s defined: 
 -- lexicographical ordering
instance Monoid Ordering where
 mempty = EQ
 LT `mappend` _ = LT
 EQ `mappend` y = y
 GT `mappend` _ = GT
 Without the comment I don’t know if I would have gotten it right away, but
check this…