How to pass around global or local state implicitlyOctober 6, 2019
In my scenario I’ve functions, a few of which will use global state, some of which can use local state like the function parent or scope scope, others which use both.
So for example you May Have stuff like that:
Say I have a 100 functions which all behave on the global state. 1 thing I can do is move it to each purpose:
Function afunction(say,. .
But I’m not certain I need to do so because it might require removing the simplicity and clarity of all the purposes. I like the concept of having special international variables that you mention in the code. But, I really don’t wish to be assigning arbitrary worldwide variables.
So one solution I am kind of imagining is having the function definition include the global factor, just if it immediately utilizes it. Then somehow it has injected in or something. Subsequently any subfunctions which use the global factor, in addition they get it perceptible in rather than passed down.
Fundamentally the end aim is I think to not pollute all the functions with these at least two variables (global state, and local scope), yet still be able to use them at any function. Wondering what kinds of solutions exist for this. I attempted to test out Haskell’s State Monad, but not even being a Haskell programmer I don’t see how it functions.