Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

README.md

elephant

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.

About

No description, website, or topics provided.

Resources

Releases

No releases published

Packages

No packages published