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
localfor MonadReader r (Process r).I don't like the name and open to suggestions.
Used like this: