Functional Purity using 'let' in Haskell
haskell
Solution
Your second `let` creates a new binding for `e` that shadows the existing variable. It does not modify `e`. You can easily check this with the following:
Prelude> let e = 1
Prelude> let f () = "e is now " ++ show e
Prelude> f ()
"e is now 1"
Prelude> let e = 2
Prelude> e
2
Prelude> f ()
"e is now 1"
Prelude>
Problem
As I am working on learning Haskell, I understand it is a purely functional language. I am having trouble understanding why `let`-statements don't violate purity. For example (in ghci): ``` Prelude> let e = exp 1 Prelude> e 2.718281828459045 Prelude> let e = 2 Prelude> e 2 ``` isn't my second `let` statement producing a side effect? Or is the second `let` statement a new closure?