[Haskell-cafe] Monad laws in presence of bottoms

Dan Doel dan.doel at gmail.com
Tue Feb 21 17:54:33 CET 2012

On Tue, Feb 21, 2012 at 10:44 AM, wren ng thornton <wren at freegeek.org> wrote:
> That's a similar sort of issue, just about whether undefined ==
> (undefined,undefined) or not. If the equality holds then tuples would be
> domain products[1], but domain products do not form domains!
> ...
> [1] Also a category-theoretic product.

This doesn't make much sense to me, either. If it's a category
theoretic product in a category of domains, then the product must be a
domain, no?

> In order to get
> a product which does form a domain, we'd need to use the smash product[2]
> instead. Unfortunately we can't have our cake and eat it too (unless we get
> rid of bottom entirely).

You don't have to get rid of bottom entirely (I think). If you make
matches against products irrefutable, then you're again in the
situation of seq being the only thing able to distinguish between _|_
and (_|_, _|_), so we could keep the current implementation (which is
efficient) without it being possible to observe within the language.
You just have to make seq not be magic on products. Miranda did this,
except it still had a seq which exposed the lie.

The problem with this is that you can easily build up a product that
is a bunch of thunks and cause a stack overflow; I _think_ that's more
of a concern than doing the same with a function. So in practice it
might be harder to do without seq on tuples.

-- Dan

More information about the Haskell-Cafe mailing list