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
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>