This repository contains the supplementary material associated to the article Towards Optic-Based Algebraic Theories: the Case of Lenses (J. López-González and Juan M. Serrano), submitted to Trends in Functional Programming 2018. In essence, it contains Coq definitions and theories revolving around very well-behaved lenses and MonadState. They are summarized in the following figure.
Broadly, we show that:
- MonadState generalizes lens. Particularly,
MonadState A (state S)
is isomorphic tolens S A
. Given this situation, we will refer to MonadState as lens algebra (lensAlg
). - A monad morphism
state A ~> state S
is isomorphic tolens S A
. - We can abstract away
state S
from the aforementioned monad morphism, obtaininglensAlg'
as a result. In other words,natLens S A
is exactlylensAlg' (state S) A
. lensAlg
is isomorphic tolensAlg'
, and hence MonadState.- We can also abstract away
state A
fromlensAlg'
, obtaininglensAlgHom
. In other words,lensAlg' p A
is exactlylensAlgHom p (state A) A
. lensAlgHom p q A
induces a lawfullensAlg A p
.