There’s a well-known problem called the Towers of Hanoi, in which n disks, all different sizes, are placed onto three rods to form towers. The goal is to move between various configurations while following two rules.
The famous version of this problem starts with all the disks on the first tower, and then asks you to move them all to the last…
Highlights of this release include:
WholeMethodMatchertype in an expectation to write a custom predicate that looks at more than one argument at a time when deciding whether to match a method call.
whenever. You should prefer to avoid this and use expectations instead, since if you’re not careful side-effects can accidentally match method calls that you weren’t looking for. But occasionally this can be very useful.
Before COVID-19 left its mark on the world, a group of us met one a month in New York for the “Haskell Cohack”, hacking together on Haskell programming projects of various forms. We had people there to learn Haskell or teach it, to talk about category theory, to work on core libraries, or just to fiddle around with programming problems like Project Euler or Advent of Code. It was great fun! But then this virus shut down the city, and we have missed our monthly meeting ever since.
I’ve just released a small update to HMock, the Haskell mock testing framework which I first released following Zurihac. Here’s what’s new in the new version.
First, HMock can now reject ambiguous expectations. Suppose had a mock filesystem monad with HMock, and you wrote something like this:
expect $ ReadFile_ anything |-> "some content"
expect $ ReadFile "foo.txt" |-> "foo content"x <- readFile "foo.txt"
With HMock 0.1,
"foo content". The more recent expectation matches before earlier expectations. This is often what you want. But Svenningsson et al argue very strongly in An Expressive Semantics of Mocking that…
At the end of Zurihac this year, I released a preview version of HMock, a new library for testing with mocks in Haskell. Let’s talk about what this is, why I wrote it, and how you can use it.
Let’s suppose I want to write a chatbot in Haskell. I might start with a few types, like so…
newtype User = User String deriving (Eq, Show)
data PermLevel = Guest | NormalUser | Admin deriving (Eq, Show)
newtype Room = Room String deriving (Eq, Show)
data BannedException = BannedException deriving (Show)instance Exception BannedException
Now I need to log in…
Last November at the Haskell eXchange conference, Simon Peyton Jones announced the Haskell Foundation. This can be understood as many things: an organization dedicated to the hard work of making Haskell more successful and useful, a touchpoint for different parts of the Haskell community to come together and cooperate, and a focus knob to direct general support (financial and otherwise) for the Haskell community and maximize its impact.
I recently decided to become a major contributor to the Haskell Foundation, and I’m writing about the reasons behind my decision. I also hope to encourage others who can easily do so…
I have always loved finding those parts of mathematics where big ideas just pop out almost by accident, appearing fully formed in a surprising and delightful way. Who, for example, could fail to marvel at how topology manages to capture so many unique and striking meanings into words like continuous which can mean very different things just by choosing a different topology in which to interpret the same definition?
Something like this happens in categories by considering limits and colimits. One simply draws a simple picture, follows a simple set of rules, and important ideas pop out. …
Here are two theorems from game theory, which initially seem to contradict each other. By comparing them, we can uncover some hidden nuance in the situation.
The first theorem, initially by Allan Gibbard and generalized by later work by Gibbard and others, showed that any collective decision-making process must have one of three properties:
In this article, we’ll develop a Haskell library for continued fractions. Continued fractions are a different representation for real numbers, besides the fractions and decimals we all learned about in grade school. In the process, we’ll build correct and performant software using ideas that are central to the Haskell programming language community: equational reasoning, property testing, and term rewriting.
Let’s start with a challenge. Assume I know how to…
This is the story of an interesting flight of fancy with mathematics. I found it intriguing, and hope you do, as well.
Here’s a fact that comes up in high school mathematics: you can demote multiplication into addition by using logarithms. That is:
That is, you can compute the log of a product, given only the logs of the factors.
To students today, this might seem like just another algebraic identity. But in the age before calculators, it was actually the main reason for a typical high school student to be interested in logarithms at all! Multiplication is more difficult…
Software engineer at Facebook, volunteer math and computer science teacher, author of the CodeWorld platform, amateur ring theorist, and Haskell enthusiast.