Go to file
Sanchayan Maity 4d3bc29f81 Add comments showing CPS and store lens idea
Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
2020-03-22 19:44:17 +05:30
src Add comments showing CPS and store lens idea 2020-03-22 19:44:17 +05:30
test Add doctests.hs where the cabal file expects it 2018-05-10 12:22:08 +10:00
.ghci Initial set of exercises, no answers 2015-05-19 09:10:42 +10:00
.gitignore Ignore tags file 2019-08-28 00:34:08 +05:30
LICENCE init 2015-04-22 12:52:34 +10:00
README.markdown Compile with more recent versions of GHC. 2017-04-20 11:05:43 +10:00
Setup.hs nix 2018-04-04 12:16:48 +10:00
changelog init 2015-04-22 12:52:34 +10:00
default.nix nix 2018-04-04 12:16:48 +10:00
lets-lens.cabal formatting updates 2019-01-28 18:59:45 +07:00
lets-lens.nix nix 2018-04-04 12:16:48 +10:00
shell.nix nix 2018-04-04 12:16:48 +10:00
stack.yaml stack.yaml: Update stack lts 2019-11-19 18:52:49 +05:30


Let's Lens

Let's Lens presents a series of exercises, in a similar format to the Data61 functional programming course material. The subject of the exercises is around the concept of lenses, initially proposed by Foster et al., to solve the view-update problem of relational databases.

The theories around lenses have been advanced significantly in recent years, resulting in a library, implemented in Haskell, called lens.


The exercises take into account various possible goals. For example, if you wish to study the history of lenses, then build up to the most recent theories, it is best to start at the Lets.GetSetLens module. If you wish to derive the structure of lenses from first principles, then derive the more modern theories, start at the Lets.Lens module.

Exercises can be recognised by filling in a function body that has a placeholder of error "todo: <function-name>".

Exercise modules


This module presents a series of exercises, representing lenses as a traditional pair of "get and set" functions. This representation may be beneficial as it easily appeals to an intuition of "what a lens is", however, it is outdated.

These exercises are useful to gain an initial understanding of the problems that lenses solve, as well as to gain an insight into the history of lenses and how the theories have developed over time.


This series of exercises is similar to Lets.GetSetLens, however, using a slightly altered representation of a lens, based on the Store comonad, which fuses the typical get and set operations into a data structure. This representation is described in detail in Morris, Tony. "Asymmetric Lenses in Scala." (2012).


This series of exercises introduces a new representation of lenses, first described by Twan van Laarhoven. This representation also introduces a generalisation of lenses to permit polymorphic update of structures.


This series of exercises starts at first principles to derive the concept of a lens, as it was first described by Twan van Laarhoven. The derivation then goes on to described other structures to solve various practical problems such as multi-update and partial update.

This representation presents a generalisation, permitting polymorphic update over structures. After lenses are derived, further concepts are introduced, such as Folds, Traversals and Prisms.