In the previous post, I explained how I refactored the language-puppet
catalog compiler so that the main monad was a pure Program
(from the operational
package) instead of an ErrorT Doc (RSST InterpreterReader InterpreterWriter InterpreterState IO)
. I then wrote an interpreter that would turn it back to this monad stack, so that it could be used with runErrorT
and runRSST
.
It might have been obvious to many readers that this was a pretty strange move, but I didn’t figure it out until operational
’s author told me (thanks !). Here is what my interpreter signature was :
1 2 3 |
|
And here is what it should have been from the beginning :
1 2 3 4 |
|
The Program
should have been converted to the base monad (IO
in this case) in the first place, instead going through the intermediate monad stack transformer step. The interpreter is now a lot easier to read.