 However if you consider the "state of the world" before and after running the code as its input and output, you get a clean function.Composition of such functions corresponds to running the procedures one after the other.The monads formalism uses this idea to incorporate side effects and I/O into functional languages.