-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add withProcess #53
base: main
Are you sure you want to change the base?
Add withProcess #53
Conversation
It's unfortunate that that |
I believe the intent was/is for all I'd be happy to be proven wrong, though! |
They can share global data if that is what's needed downstream: host :: Process Global ()
host = do
localData <- setup...
spawn onlyGlobal
withProcessEnv (const localData) $ spawn onlyLocal
withProcessEnv (, localData) $ spawn hasBoth
...
hasBoth :: Process (Global, Local) ()
globalData <- asks fst
... Of course if you need common data you don't want to drop it entirely. And So the alternative is using awkward and non-total wrappers: data GlobalAndLocal = Both
{ common :: Int
, specific :: Maybe Socket -- awkward
}
data GlobalOrLocal
= Common Int
| Specific Socket -- oops, lost that "global node data" anyway |
I will try to lift env into process and see what happens... |
Adds withProcessEnv (like withReaderT) - a more general `local` for MonadReader r (Process r).
It was pleasantly simple. The changes got contained in the |
Hmh, I still wasn't able to remember why I made everything a In any case, given the change you suggested, does |
Maybe there shouldn't be a default A user then can easily recover
|
A more general
local
for MonadReader r (Process r).I don't like the name and open to suggestions.
Used like this: