title: haskell: RPN Calculator
body: <p>I want to develop a sort of stack managing system. The list starts by being empty [] and a user can input numbers and they will be added to the list, as well as binary operations, which will take two first numbers from a list and perform the operation and then put it back on the list. EG:</p>
  
  <pre><code>[] : 3
  [3] : 4
  [4,3] : +
  [7] : c
  [] : 123
  [123] : 3
  [3,123] : *
  [369] :
  </code></pre>
  
  <p>I cannot figure out how to process input from the console. I have this broken code:</p>
  
  <pre><code>import System.Environment   
  import System.Directory  
  import System.IO  
  import Data.List  
  
  stack = []
  
  add1 :: [Int] -&gt; [Int]
  add1 [] = []
  add1 [x] = [x]
  add1 [x,y] = [(x+y)]
  add1 x:(y:xs) = (x+y) : (xs : []) 
  
  --sub :: [Int] -&gt; [Int]
  --sub [] = []
  --sub x:(y:xs) = (x-y) : xs 
  
  --mul :: [Int] -&gt; [Int]
  --mul [] = []
  --mul x:(y:xs) = (x*y) : xs 
  
  --div :: [Int] -&gt; [Int]
  --div [] = []
  --div x:(y:xs) = (x/y) : xs 
  
  c :: [Int] -&gt; [Int]
  c = []
  
  push :: [Int] -&gt; a -&gt; [Int]
  push [] a = [a]
  push (x:xs) a = a : (x:xs)
  
  dispatch :: [(String, Int -&gt; IO ())]
  dispatch =  [ ("+", add)
         --     , ("-", sub)
         --     , ("*", mul)
         --     , ("/", div)
              ]
  
  xcl = do
      print stack
      answer &lt;- readLine
  </code></pre>
  
  <p>But I don't even know if I'm heading in the right direction. Any help will be great. Thank you.</p>