Patterns for computational effects arising from a monad or a comonad
Résumé
We propose patterns for proving properties of programs involving computational effects, in the framework of decorated logics. Although this framework does not mention monads nor comonads, it can be instantiated for a combination of monads and comonads. We propose two dual patterns. The first one provides inference rules which can be interpreted in the Kleisli category of a monad and the coKleisli category of the associated comonad. For instance, in this pattern, the raising of exceptions corresponds to the exception monad (with endofunctor $A+E$) on some category and their handling corresponds to a comonad (with the same endofunctor $A+E$) on the Kleisli category of the monad. In a dual way, the second pattern provides inference rules which can be interpreted in the coKleisli category of a comonad and the Kleisli category of the associated monad. For instance, in this pattern, the lookup operation on states corresponds to the comonad with endofunctor $A\times S$ and the update operation corresponds to a monad on the coKleisli category of the comonad. Each pattern consists in a language with an inference system. This system can be used for proving properties of programs which involve an effect that can be associated to a monad (respectively a comonad). The pattern provides generic rules for dealing with any monad (respectively comonad), and it can be extended with specific rules for each effect.
Origine : Fichiers produits par l'(les) auteur(s)