-
Anyone knows how to implement an interpreter for the type Reg = Int
data Asm :: Effect where
Later :: Asm m a -> Asm m a
WithReg :: (Reg -> Asm m a) -> Asm m a
type instance DispatchOf Asm = Dynamic
later :: (Asm :> es) => Asm (Eff es) a -> Eff es a
later = send . Later
withReg :: (Asm :> es) => (Reg -> Asm (Eff es) a) -> Eff es a
withReg = send . WithReg The expected semantics is that with I've tried the code below, but I'm not sure how to proceed next: run :: Eff (Asm : es) a -> Eff es a
run = reinterpret (runReader $ mkReg 0) \ -> \case
Later m -> _whatNext1 -- how do we interpret `m`???
WithReg kont -> do
reg <- get @Reg
_whatNext2 $ kont reg -- how to continue ? |
Beta Was this translation helpful? Give feedback.
Answered by
smunix
Aug 7, 2022
Replies: 1 comment 2 replies
-
Looking how |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
arybczak
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looking how
CatchError
is interpreted, I believe I may need to do the same thing as here