archives

A duality between exceptions and states - Dumas, Duval, Fousse, Reynaud

Interesting observation that the state comonad (sometimes known as the product comonad) and exception monad are dual:

T A = A × X (state comonad)
T A = A + X (exception monad)

A duality between exceptions and states

The duality between categorical products and sums can be extended as a duality between the semantics of the lookup and update operations for states on one side and the semantics of the constructor [throw] and recovery operations [catch] for exceptions on the other side.