Immutability
At this point in our training, you need to learn that all values in Haskell are immutable! But what does it mean for us? It means that when you apply a function to some argument, the value of that argument cannot be changed. Instead, you create a new value each time. That means "variable assignment" does not exist in Haskell. Instead, we only assign a name to an expression and we know that that name will always evaluate only that expression.
1
ghci> let a = [1,2,3]
2
ghci> reverse a -- reverse is a function that reverses a list
3
[3,2,1]
4
ghci> a -- the value of the expression "a" never changed
5
[1,2,3]
Copied!
Copy link