Create a Dreamwidth Account
Site and Account
Reload page in style:
2013-04-20 04:53 am (UTC)
The reader monad with just
isn't dynamic scope; it's just "global" variables. Adding
then allows you to have multiple stages of "globality"; i.e., it's a way to lie about there being a
operation on reader monads... or, well, not lie so much as bend the truth by giving local views of the global state (including the
The thing with dynamic scope is all about mutation IMO. I guess you could call the reader monad with
a form of dynamic scope, but I don't think that's really appropriate. For example, with dynamic scope you can use a loop to perform a bunch of mutation and then view the effects of that after the loop exits (so long as you don't exit the current stackframe). Can you achieve this with the reader monad? Bear in mind that every time you call
you're explicitly pushing a new "stackframe" which gets popped when the second argument returns.
You can certainly model parts of dynamic scope with the reader monad, but that's because you can model both of them by explicitly passing immutable state around. The reader monad doesn't introduce the reasoning difficulties that dynamic scope does. Even if you're trying to model DS, the details of making that model explicit will get in the way of the reasoning difficulties. There's nothing wrong with dynamic scope— except when that's not what you want.
Thread from start
This account has disabled anonymous posting.
You can comment on this post while signed in with an account from many other sites, once you have confirmed your email address.
Sign in using OpenID
If you don't have an account you can
create one now
HTML doesn't work in the subject.
Check spelling during preview
This account is set to log the IP addresses of everyone who comments.
Links will be displayed as unclickable URLs to help prevent spam.
Expand Cut Tags
No cut tags
Page generated Oct. 21st, 2017 03:12 am
Top of page