3 ms·
No. "In place" has virtually no meaning in Haskell. I find this very interesting -- a popular idiom in one language can't even be represented in another.
by lincolnq 16y ago
No. "In place" has virtually no meaning in Haskell.
I find this very interesting -- a popular idiom in one language can't even be represented in another.
- sesqu 16y agoOne of the biggest reservations I initially had about abstraction, when learning programming, was that I didn't consider performance a detail. As such, I didn't litter my code with objects or pure functions even when they made conceptual sense, unless I was convinced the overhead was small and the abstraction helpful. I've found that languages like Java make assumptions about your memory, and languages like Prolog make assumptions about your data. I'm under the impression that in Haskell in-place modification is an interpreter optimization, whereas C is increasingly employed when resources are constrained and abstraction layers are deemed too costly. Consequently, C is maligned for resulting in faulty implementations behind every corner, yet it remains one of the most used languages.
- eru 16y agoThe Haskell compiler is free to use in-place mutations, when it can prove that nobody can access the old object any longer. The language Clean supports this notion explicitly in its type system (and uses it for IO, instead of, say, Monads like Haskell).
- eru 16y agoYou can do replace stuff in-place (and other low-level stuff) in the IO Monad.