Work from Ulf Norell's Agda tutorial