3 ms·
If you start with a pure and strict programming language, how will you handle side effects?
by tasuki 2y ago
If you start with a pure and strict programming language, how will you handle side effects?
- kccqzy 2y agoThe same way as a pure and lazy programming language. That is to say, the IO monad. This abstraction works for both lazy and eager evaluation because it's internally just passing a token from function to function. When you have something like `doThis >> doThat` (two actions sequentially) the first action results in a token (RealWorld#) that must be passed into the second action. Even though the evaluation of the two actions may be undetermined in a lazy language (but determined in a strict language), the token being passed around has a definite order.
- tasuki 2y agoThat was kind of my point, but thanks for laying it out nicely, I guess :)
- mcguire 2y agoSide effects like IO are very difficult to handle in a pure language. I believe Simon Peyton Jones' argument was that, if it's strict, there is too much of a temptation to say, "screw it", and abandon purity. https://www.microsoft.com/en-us/research/publication/wearing-hair-shirt-retrospective-haskell-2003/ https://www.microsoft.com/en-us/research/publication/wearing...
- tasuki 2y agoMuch respect for Simon Peyton Jones, but empirically, that's not true: see Idris, PureScript, Elm, and probably many others.
- mcguire 2y agoThose were all designed after monadic IO was introduced in Haskell. The ability to mark IO operations in types (and the do notation) was a game-changer.