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 Sis isomorphic tolens S A. - We can abstract away
state Sfrom the aforementioned monad morphism, obtaininglensAlg'as a result. In other words,natLens S Ais exactlylensAlg' (state S) A. lensAlgis isomorphic tolensAlg', and hence MonadState.- We can also abstract away
state AfromlensAlg', obtaininglensAlgHom. In other words,lensAlg' p Ais exactlylensAlgHom p (state A) A. lensAlgHom p q Ainduces a lawfullensAlg A p.
