[Haskell-beginners] parse String -> Expression

John Moore john.moore54 at gmail.com
Sun Nov 8 12:53:48 EST 2009

    I'm trying to find a way to parseRPN (Reverse Polish Numbers) to
expressions rather than to just numbers. e.g. I want the answer to be in the

(Multiply (Val 2) (Val 3)) rather than just the answer.

Are these anyway near the steps
parseRPN :: String->Expression

This is a lot more complicated then I thought.!!!

First do we have to read in a string is this (IsString)

 fromString :: String -> a

Then this goes on a stack

pushStack :: a -> Stack -> Stack (Takes a value and puts in on a stack)

Later we pop it off

popStack :: Stack -> (a,Stack) -- takes the value of the stack and leaves
the stack

Do we also have to define taking off the stack such as head(popstack) or
fst(popstack) if we do we would probably have  one for putting it onto a

Do we then turn the value into an Expression.?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20091108/4fec4429/attachment.html

More information about the Beginners mailing list