Skip to content

Handling the same effect multiple times with interpret and interpose #38

Description

@koslambrou

Here's self-containing example:

data MyEffect r where
    Execute :: MyEffect ()

makeEffect ''MyEffect

handleFirstEffect :: (LastMember IO effs) => MyEffect ~> Eff effs
handleFirstEffect = \case
    Execute -> liftIO $ print "handleFirstEffect"

handleSecondEffect :: (LastMember IO effs) => MyEffect ~> Eff effs
handleSecondEffect = \case
    Execute -> liftIO $ print "handleSecondEffect"

main :: IO ()
main = do
  runM
     $ interpret handleSecondEffect
     $ interpose handleFirstEffect execute

The programs prints only handleFirstSecond, but does not print handleSecondEffect. I would have expected to also print the latter, since interpose should allow someone to respond to the effect while leaving it unhandled.

Bug or is there's something I'm not understanding?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions