News for hackers. Stuff that matters.
Re:Haskell Problems for a New Decade by pjmlp on Friday January 24, 2020 @12:36PM (#22140490)
Monads are from category theory, so at most they were adopted, not developed.

They are a workaround, because by definition purity implies that nothing changes in the world.

I can run the same Haskell program multiple times, and it might eventually produce different values as output given the same input values, e.g. an URL or file handle.

Re:Haskell Problems for a New Decade by TheAsprngHacker on Friday January 24, 2020 @01:24PM (#22141013)
Are you referring to how an online document or a file might change so that Haskell program might have a different output given the same URL as an input?

As @willtim explains, monads were applied to PL theory to model effects. The IO monad models the effect of state, i.e. imperative programs. The type `IO a` is essentially a "wrapper" or "alias" for the type `RealWorld -> (RealWorld, a)`. You should think of the entire world as being the input to a Haskell program.

Haskell does have impure backdoors into IO such as unsafePerformIO, but the IO monad itself is perfectly pure.

P.S. For more information, check out the work of Eugenio Moggi [0], who started using monads to give semantics to programming languages, and Philip Wadler [1], who applied the idea on a programmer-facing level.

[0] https://person.dibris.unige.it/moggi-eugenio/ftp/ic91.pdf

[1] https://groups.csail.mit.edu/pag/OLD/reading-group/wadler-mo...

Re:Haskell Problems for a New Decade by willtim on Friday January 24, 2020 @12:51PM (#22140657)
Purity applies to the process of program construction. This is still very valuable, as I can better reason about program correctness.