As a programming exercise I'm trying to use the State monad to create a simple parser.  It's for a very simple assembly language for a simple virtual machine.  The state is a string of instructions.  I want to be able to call something like getNextInstruction to pull out the next instruction and then update the state (string).  I know I can do this non-monadically by just passing the string explicitly each time but I'd like to learn more about the State monad.  I also know about Parsec and Happy and so forth but this is just an exercise so I want to do it this way.  Any ideas?  I can't seem to get anything to work.  I've tried different things but I suspect I'm just missing something basic.  Can someone post a simple prototype for this?  Just assume the instructions are integers.


Pinpoint customers who are looking for what you sell.