←back to thread

498 points azhenley | 3 comments | | HN request time: 0.231s | source
Show context
y0ned4 ◴[] No.45769960[source]
When I started programming in Haskell, where all variables are immutable, I felt like I was in a straitjacket

Then, suddenly, the enlightenment

replies(5): >>45770377 #>>45770438 #>>45770896 #>>45771052 #>>45771863 #
1. criddell ◴[] No.45771052[source]
How does Haskell deal with things like memory-mapped I/O or signal handlers where the value of a variable can be changed by factors outside of the programmer's control?
replies(2): >>45771504 #>>45771883 #
2. how_gauche ◴[] No.45771504[source]
Side effecting computations that depend on the "real world" go into an IO monad. The game in Haskell is shifting as much of the codebase as possible into pure functions/non-side-effecting code, because it's easier to reason about and prove correct.
3. chuckadams ◴[] No.45771883[source]
IORefs usually, which can only be manipulated within the IO monad, so they tend to only get used at the top level and passed down to pure functions as parameters.