title: Possible to read files in pure code in Haskell?
body: <p>I am writing a compiler for a DSL. After reading the source file into a string, all the rest steps (parsing, type checking, and codegen) are all pure code, transforming the code from one representation to another. All is good till there are dependencies in the source file (think of <code>#include</code> preprocessor in <code>C</code>). The parser needs to read the dependent files and recursively parse them. This makes it not pure anymore. I have to change it from returning <code>AST</code> to <code>IO AST</code>. Also, all the subsequent steps (type checking and codegen) have to return IO types as well, which requires significant changes. What is a good way to handle reading dependent files in this case?</p>
  <p>p.s. I can use <code>unsafePerformIO</code>, but that seems a hacky solution that can lead to technical debt.</p>