Louis Dionne Programming and Categories, Oh My!

A mathematical intuition for empty variants and tuples

The goal of this post is to introduce sum types and product types from a very high level perspective, and to try and derive an intuition for what the meaning of tuple<> and variant<> should be. The mathematics in this post are purposefully kept a bit vague, because being more formal would make the post heavier.

Laziness as a Comonad

This (first!) post will present my current understanding of how laziness can be represented as a Comonad. The interest of seeing laziness as a Comonad appeared while working on a C++ metaprogramming library called Hana as a possible generalization of the eval_if construct from the MPL library. More generally, anyone trying to implement a domain-specific language with a notion of branching inside a strict language (as opposed to non-strict like Haskell) will have to design a system to emulate laziness, in order to evaluate only the branch that was picked by the condition. This post is an attempt to describe such a system using the notion of Comonad.