Comment on Unison | A friendly, statically-typed, functional programming language from the future · Unison programming language

<- View Parent
Pipoca@lemmy.world ⁨6⁩ ⁨months⁩ ago

Pure functions should be referentially transparent; you should be able to replace them with whatever value they evaluate to without changing the semantics of your code.

Throwing is referentially impure: what value do you get from calling x => throw new RuntimeException()?

Instead, functional languages prefer to return a tagged union of the value or the error.

source
Sort:hotnewtop