2 ms·
...and using the ST monad. In the end it pretty much ends up looking like an imperative program. The good news is that it stops at the function boundaries. You
by danieldk 13y ago
...and using the ST monad. In the end it pretty much ends up looking like an imperative program.
The good news is that it stops at the function boundaries. Your quicksort may be implemented in the ST monad, looking like some bastard child of C, but the function type ends up being
qsort :: Ord a => Vector a -> Vector a
And that's one of the likeable properties of Haskell: it doesn't deny that real-world programs sometimes require mutability, but allow you to isolate it through the type system. So, even though qsort may use mutable memory for sorting, it is a pure and referentially transparent function.