
Does "impurity" from something like a random number generator or file I/O have to move it's way all the way through my code?
No, only through the parts that actually have to do file I/O or generate random numbers or whatever. However, cleanly separating the IO code from the non-IO/"pure" code takes some experience. It does seem to be a common experience of people learning Haskell that IO ends up "infecting" everything, even stuff that shouldn't have to do any IO, but with good design this is not necessary. In your particular case, your matrix generation function does depend on random number generation so it makes sense that its type must involve IO. However, if you go on to write other functions which do deterministic operations on matrices, their types should *not* involve IO, even if you pass randomly generated matrices to them as arguments. -Brent