Skip to content

monadCont instance doesn't preserve cancellation behavior #46

@natefaubion

Description

@natefaubion

I found this while working on a test for cancelling forkAll.

delay :: forall eff. Int -> Aff eff Unit
delay n = callCC \cont ->
  later' n (cont unit)

fork :: forall eff. Aff (console :: CONSOLE | eff) Unit
fork = do
  a <- forkAff (later' 10000 (Console.log "oops"))
  cancel a (error "bye")
  Console.log "Canceled a"
  b <- forkAff (do delay 10000
                   Console.log "oops")
  cancel b (error "bye")
  Console.log "Canceled b"

I would assume that the two formulations would be identical, but the callCC version does not cancel correctly. The first variation (using later' directly) gets cancelled correctly and prints "Canceled a". While the callCC variation waits 10 seconds, then get's cancelled, but does not print anything.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething that should function correctly isn't.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions