How to read from a file using Haskell? : <p>I am trying to read from a file. I want to split each line from a file into its own string. I am thinking of using the lines command in order to make a list of Strings of all the lines. I then plan to use the words command to spilt each line into a list of words. However, I am very new to functional programming/Haskell, and I don't fully understand the syntax. So, to begin, how do you read each line from a file and store it? </p>

<p>I attempted the following code, but it does not compile. </p>

<pre><code>main :: IO ()
main = do
  contents &lt;- readFile "input.txt" 
  contents1 = lines contents
</code></pre>
