Towards Optic-Based Algebraic Theories
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 to
lens S A. Given this situation, we will refer to MonadState as lens algebra (
- A monad morphism
state A ~> state Sis isomorphic to
lens S A.
- We can abstract away
state Sfrom the aforementioned monad morphism, obtaining
lensAlg'as a result. In other words,
natLens S Ais exactly
lensAlg' (state S) A.
lensAlgis isomorphic to
lensAlg', and hence MonadState.
- We can also abstract away
lensAlgHom. In other words,
lensAlg' p Ais exactly
lensAlgHom p (state A) A.
lensAlgHom p q Ainduces a lawful
lensAlg A p.