No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


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:

  setElephant 2

When the value of elephant is initialized as zero, this program prints 0 and then 2.