-
I have a bit of an interesting situation, and I'm curious if I have one data Hardware :: Effect where
WithResizedMoverAt :: EventWriter :> es => MoverId -> Point V2 Int -> Maybe (V2 Length) -> Eff es a -> Hardware (Eff es) a As you can see, calling data EventWriter :: Effect where
AppendEvent :: ToJSON a => a -> EventWriter m ()
runEventWriter ::
forall {es} job a.
(IOE :> es, DB :> es, Show job) =>
JobId ->
job ->
Eff (EventWriter : es) a ->
Eff es a I also have an interpreter for runHardware :: (IOE :> es, Statement :> es) => HW.Hardware -> Eff (Hardware ': es) a -> Eff es a
runHardware hw m = do
initialState <- newState
reinterpret (evalState initialState) interpreter m
where
interpreter ::
(IOE :> es, State HardwareState :> es, Statement :> es) =>
LocalEnv localEs es ->
Hardware (Eff localEs) a ->
Eff es a
interpreter env = \case
WithResizedMoverAt moverId targetLocation newSize k ->
...
routerMover ... Where routeMover :: (IOE :> es, EventWriter :> es) => HW.Hardware -> RouteMover -> Eff es () Notice that In terms of usage, I essentially have: runHardware hardware do
runEventWriter job1 j do
..
runEventWriter job2 k do
.. though in reality these are really two separate job queues. From a high-level, my goal is to have:
If this is still confusing, let me know and I can try and put a minimal example together. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
My current solution is: Change the type of routeMover :: (EventWriter :> es, IOE :> es') => (forall a. Eff es' a -> Eff es a) -> HW.Hardware -> RouteMover -> Eff es () Then I can do: WithResizedMoverAt moverId targetLocation newSize k ->
localSeqUnlift env \unlift ->
localSeqLift env \lift ->
..
unlift $ routeMover
lift
hw
RouteMover A bit ugly, and a shame I had to change |
Beta Was this translation helpful? Give feedback.
-
Hmm, that's an interesting situation. I think #196 is a solution, right? With |
Beta Was this translation helpful? Give feedback.
Hmm, that's an interesting situation.
I think #196 is a solution, right? With
localSeqHandle
(name subject to change, suggestions welcome 😛 ) You can captureIOE
in the handler environment and "graft" it on top oflocalEs
.