by dustingetz · 13y ago · 0 comments
An example where this shines is writing interpreters. You can write a "calculator" interpreter in identity monad, then add an environment (functions and lexical scope), then add errors, then make the environment mutable, then add continuations and try/catch. The core eval loop does not change as you implement new keywords like 'def' or 'throw'. In an imperative interpreter, each feature is coupled with the interpreter core.
I've done this in python but writing pure code in python is so crappy that it's not even worth sharing. Here is a short blog post though with code samples:
http://www.dustingetz.com/2012/10/02/reader-writer-state-mon...
No comments yet.