klequis / zz-haskell-notebook

Notes from learning Haskell
1 stars 0 forks source link

Referential transparency #69

Open klequis opened 2 years ago

klequis commented 2 years ago

In purely functional languages, a function has no side-effects. The only thing a function can do is calculate something and return it as a result. If a function is called twice with the same parameters, it's guaranteed to return the same result. This called referential transparency.

Referential transparency and not only does it allow the compiler to reason about the program's behavior, but it also allows you to easily deduce (and even prove) that a function is correct and then build more complex functions by gluing simple functions together.

Source: Learn You a Haskell for Great Good!