3 ms·
Purely functional programming languages can't have side effects. But they can have intended effects. Like Haskell, TopShell uses monads to represent effects, a
by continuational 7y ago
Purely functional programming languages can't have side effects. But they can have intended effects.
Like Haskell, TopShell uses monads to represent effects, and eg. Http.fetch returns a Task, which is similar to the IO monad in Haskell.
The returned Task is a pure description of how to perform the HTTP request. Every time you apply Http.fetch to the same arguments, you get exactly the same description back, thus maintaining referential transparency.
Only the top level knows how to interpret such a description and perform the effects (eg. open a HTTP connection etc). Thus you compose Tasks into bigger tasks and then let the top level run them.