-
Notifications
You must be signed in to change notification settings - Fork 11
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
Adapter for effectful effects library #162
Conversation
Replace the problematic use of (:>>) with series of (:>).
Thanks again to @guaraqe's help yesterday, this is looking good. I'm going to add some Haddock documentation based on the example EffectSnippet.hs that we worked though and then this will be good! |
Rename `runProgram` to `withProgram'`, paralleling the main `withProgram`. Update the comments so the comparison between the two is clear.
One problem I can think of is that the Context that is current right before the |
Thanks for putting my name there! Do you have an example of this... context changing between layers? |
You're right, I'll need to make an example that shows the problem. |
The best I can do is something like this:
which doesn't really help, other than to note that the parent inside I have an idea of what to do about this; I'll have a go. If I get stuck I'll post the code that generated the above. |
Sorted it out with withProgram action = do
-- extract Context τ
ProgramE context1 <- Effect.getStaticRep
-- lift to IO, using the provided specialized function which gives an unlift
-- function for later use.
Effect.withEffToIO $ \runInIO ->
-- now in IO. Lift to Program τ
subProgram context1 $ do
-- now in Program τ. We form the function that will run an effect
-- in Program τ, and pass it to the supplied action.
action $ \inner -> do
context2 <- getContext
liftIO $ do
-- now in IO
runInIO $ do
-- now in (IOE :> es, ProgramE :> es) => Eff es, but
-- we need to update the Context τ in the ProgramE τ
-- effect with the one that was present just before we
-- ran the unlifting function.
Effect.putStaticRep (ProgramE context2)
-- now we can proceed with running the nested effects.
inner I verified all this by inspection of the |
Nice! |
We have found ourselves in a situation where we want to use the Program monad from within a codebase that has been infested with the Eff effect system from the effectful package. This branch introduces a new ProgramE effect that allows lifting and unlifting from Eff es to Program.