[Haskell-cafe] Reflections on the ICFP 2009 programming contest

Brent Yorgey byorgey at seas.upenn.edu
Mon Jun 29 15:42:09 EDT 2009

On Mon, Jun 29, 2009 at 11:40:28AM -0700, Justin Bailey wrote:
> Anyways, for those who care, the heart of my VM implementation was a
> monadic fold over the program, with a mutable array representing the
> machine's memory, all inside ''runSTUArray.'' I used a simple data
> type to represent the machine:
> data Machine = Machine { instrs :: [OpCode]
>                        , dataMem :: UArray Int Val
>                        , outputs :: UArray Int Val
>                        , status :: !Int
>                        , inputs :: IntMap Val }
> where ''dataMem'' holds the data memory area. To execute a program, I
> folded over the ''instrs'' list and updated memory as I went:

Nice.  I did something pretty similar, although I just used
association lists for the inputs and outputs---although I bet it would
have been faster if I used arrays like you did!

I plan to post some thoughts on my blog (syndicated on Planet Haskell)
sometime later today or tomorrow.


More information about the Haskell-Cafe mailing list