3 ms·
You might be overplaying whatever fear people have of mixing imperative and functional code. It is fairly straightforward to not let mutable variables muck up
by Dewie3 11y ago
You might be overplaying whatever fear people have of mixing imperative and functional code.
It is fairly straightforward to not let mutable variables muck up pure functions -- A pure function doesn't do anything but return a value. A pure function which computes the length of a list might be implemented by an imperative procedure that loops through the list and updates a counter, which is then returned. Whether a pure function is implemented in a functional or imperative way is... an implementation detail.
As far as IO effects are concerned, Haskell's approach let's IO values be first-class. You can use regular, pure functions on, where in a different system you might indeed have to try to keep the "pure" and "impure" code separate. And they say that Haskell programmers are afraid of IO... yeah, so afraid that it is treated as a first-class concept and value. :-)