I found this great article about the inner workings of the IO monad in Haskell, and how it maintains purity in the context of functional programming:
https://pbrisbin.com/posts/the_advent_of_io/Very informative and helpful, provided you know at least a bit Haskell and monads.