title: I always get this error in Haskell when I try to do :load Rpn.hs
body: <p>This is the code I have for trying to implement a reverse Polish notation evaluator:</p>
  
  <pre><code>step :: [Int] -&gt; String -&gt; [Int] 
  step (x:y:ys) "*" = (x * y):ys 
  step (x:y:ys) "+" = (x + y):ys 
  step (x:y:ys) "-" = (y - x):ys 
  step xs numberString = read numberString:xs
  
  rpn :: [String] -&gt; Int
  rpn = head . foldl step[] . words
  </code></pre>
  
  <p>and this is error I keep getting when I do :load Rpn.hs :</p>
  
  <pre><code>Rpn.hs:9:7: error:
      • Couldn't match type ‘[Char]’ with ‘Char’
        Expected type: [String] -&gt; Int
          Actual type: String -&gt; Int
      • In the expression: head . foldl step [] . words
        In an equation for ‘rpn’: rpn = head . foldl step [] . words
    |
  9 | rpn = head . foldl step[] . words
    |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  Failed, no modules loaded.
  </code></pre>
  
  <p>I think the problem is with the foldl function but I am not quite sure about how to resolve it. Please, kindly guide me on what to do.</p>