title: Can I have separate functions for reading and writing to a txt file in Haskell, without using a 'main' function?
body: <p>I'm making a program using Haskell that requires simple save and load functions. When I call the save function, I need to put a string into a text file. When I call load, I need to pull the string out of the text file.</p>
  
  <p>I'm aware of the complexities surrounding IO in Haskell. From some reading around online I have discovered that it is possible through a 'main' function. However, I seem to only be able to implement either save, or load... not both.</p>
  
  <p>For example, I have the following function at the moment for reading from the file.</p>
  
  <pre><code>main = do  
   contents &lt;- readFile "Test.txt"  
   putStrLn contents  
  </code></pre>
  
  <p>How can I also implement a write function? Does it have to be within the same function? Or can I separate it? Also, is there a way of me being able to name the functions load/save? Having to call 'main' when I actually want to call 'load' or 'save' is rather annoying.</p>
  
  <p>I can't find any examples online of someone implementing both, and any implementations I've found of either always go through a main function.</p>
  
  <p>Any advice will be greatly appreciated.</p>