title: Haskell: I/O and Returning From a Function
body: <p>Please bear with me as I am very new to functional programming and Haskell.  I am attempting to write a function in Haskell that takes a list of Integers, prints the head of said list, and then returns the tail of the list.  The function needs to be of type [Integer] -> [Integer].  To give a bit of context, I am writing an interpreter and this function is called when its respective command is looked up in an associative list (key is the command, value is the function).</p>
  
  <p>Here is the code I have written:</p>
  
  <pre><code>dot (x:xs) = do print x
        return xs
  </code></pre>
  
  <p>The compiler gives the following error message:</p>
  
  <pre><code>forth.hs:12:1:
  Couldn't match expected type `[a]' against inferred type `IO [a]'
    Expected type: ([Char], [a] -&gt; [a])
    Inferred type: ([Char], [a] -&gt; IO [a])
  In the expression: (".", dot)
  </code></pre>
  
  <p>I suspect that the call to print in the dot function is what is causing the inferred type to be IO [a].  Is there any way that I can ignore the return type of print, as all I need to return is the tail of the list being passed into dot.</p>
  
  <p>Thanks in advance.</p>