arliss_obsidian/fp/Terminology/Referential Transparency.md

13 lines
356 B
Markdown
Raw Normal View History

2024-09-23 23:56:55 +00:00
A property of [[Purity|pure]] [[Functions|functions]] that they can always be replaced by the expression they return.
For example `add` is referentially transparent, so
```haskell
a = add 1 3
```
could be replaced with
```haskell
a = 4
```
at design- or compile-time, because `add` always returns the same result and performs no observable side-effects.