OttoAllmendinger/haskoin — pull request #3 by lornap (2014-06-28 17:13:29+00:00)
Title: Evaluating Script Changes

Hey Otto,

Here’s another set of commits.

Two of these change the structure of things so I thought I’d explain them.

ba3a0:
I removed `instructions` from `Program` and restructured the evaluation code.

It didn’t make much sense to have the instructions stored in the program state since they are evaluated sequentially and not used/changed by the OPs (outside of debugging).

`mapM` ( or equivalently `forM` ) is the usually ways to process things sequentially, so I switched to evaluating that way.

a2b99:
I split the `condStack` out into a separate `StateT` monad transformer. This is useful for type safety.

With this change, the type system will protect from evaluating OPs without passing them first through if-statement processing. That is, the output from `eval` is no longer complete to be run in a program.

I think it also makes sense structurally since `Program` contains state data that the OPs use to compute things while `IfStack` is used for program flow.

Oh. Also, `traceM` and `byteStringHex` sent me into cabal hell since they’re not available in the versions of packages in haskoin.cabal.

-Lorne