News for hackers. Stuff that matters.
Re:Show HN: Purely Functional Scripting by continuational on Sunday August 04, 2019 @05:33AM (#20605403)
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.

There are no comments on this comment yet.