This demo project was inspired by a Stack Overflow question which asks:
How can I re-assign a variable in a function in Haskell?
For example,
elephant = 0 function x = elephant = x
The short answer is that we don't have a language-level mechanism to model that sort of thing in Haskell, and it's generally not what you want anyway.
This project provides the long answer, demonstrating how to use a lens and the state monad to produce something that looks like a direct translation of the imperative-programming concept of reassigning a variable.
We end up writing a program that looks like this:
do
printElephant
setElephant 2
printElephant
When the value of elephant is initialized as zero, this program prints 0
and
then 2
.