Idempotent Applicatives, Parametricity, and a Puzzle
Some applicative functors are idempotent, in the sense that repeating an effect is the same as having it just once. An example and a counterexample are
IO, respectively (contrast
Just 3 *> Just 3 with
print 3 *> print 3). More precisely, idempotency means that
f <$> u <*> u = (\x -> f x x) <$> u. Given the informal description I began with, though, one might wonder whether the simpler property
u *> u = u, which seems to capture the intuition about repeated effects, is equivalent to the usual idempotency property. In this post, I will tell how I went about exploring this conjecture, as well as a few things I learnt about parametricity along the way.
Read more - April 1, 2019
Traversable: A Remix
Traversable is a fun type class. It lies at a crossroad, where many basic Haskell concepts meet, and it can be presented in multiple ways that provide complementary intuitions. In this post,
Traversable will be described from a slightly unusual point of view, or at least one that is not put into foreground all that often. We will suspend for a moment the picture of walking across a container while using an effectful function, and instead start by considering what can be done with effectful functions.
Read more - May 19, 2017
What's in a Fold: The Basic Catamorphism in recursion-schemes
This article is meant as an accessible introduction to the most basic recursion scheme, the catamorphism. It won’t engage in deep dives into theory, or survey practical motives for using recursion schemes – that will be covered by the further reading suggestions at the end. Rather, its main goal is simply offering a concrete presentation of how folds can be generalised. This presentation will be done in terms of the types and combinators used by the recursion-schemes library, so that the article doubles as an introduction to some of its key conventions.
Read more - March 10, 2017
Casual Hacking With stack, Reloaded
It has been quite a while since I wrote about how to use stack for casual play outside of the context of a conventional Haskell project. In the meantime, stack has gained a feature called the global project which in many cases makes it possible to do quick experiments with essentially no setup, while still taking advantage of the infrastructure provided through stack.
Read more - February 26, 2017
Migrating a Project to stack
This post consists of notes on how I converted one of my Haskell projects to stack. It provides a small illustration of how flexible stack can be in accomodating project organisation quirks on the way towards predictable builds.
Read more - July 27, 2015
It is widely agreed that the laws of the
Applicative class are not pretty to look at.
Monad laws, in comparison, not only look less odd to begin with but can also be stated in a much more elegant way in terms of Kleisli composition
(<=<). Shouldn’t there be an analogous nice presentation for
Applicative as well? That became a static question in my mind while I was studying applicative functors many moons ago. After finding surprisingly little commentary on this issue, I decided to try figuring it out by myself.
Read more - July 6, 2015