title: Couldn't match expected type with actual type
body: <p>I am a total Haskell noob and I was hoping someone could help me with this because I've been at this for hours and I just know that I'm doing something ridiculously stupid.</p>
  
  <p>The program is supposed to scan a dictionary file to determine all valid word sequences for a collection of sentences with spaces removed.</p>
  
  <p>Ex. "insidewaysoften" could be broken down to "in side ways often", "inside way soften", etc.</p>
  
  <p>I wrote my prototype in python and it works just fine (as does my Java implementation), but the course requires a Haskell implementation and I cannot get it to work. Apologies in advance for the crimes I have committed against the language and GHC with the following code:</p>
  
  <pre><code>import System.Environment   
  
  main = do
    [dictFilename,sentFilename] &lt;- getArgs  
    dictFile &lt;- readFile dictFilename
    sentFile &lt;- readFile sentFilename
  
    mapM (\sentence -&gt; solve "" "" sentence (words dictFile)) (words sentFile)
  
  solve prefix header [] dict =
    if (header `elem` dict) 
    then return prefix ++ header
    else return ""
  
  solve prefix header sent dict = do
    let more = solve prefix (header ++ (take 1 sent)) (drop 1 sent) dict
  
    if (header `elem` dict) 
    then return (solve (prefix ++ header ++ " ") "" sent dict) ++ more
    else return more
  </code></pre>