-
Notifications
You must be signed in to change notification settings - Fork 67
Open
Description
module Test.Main
( main
) where
import Prelude
import Control.Monad.Fork.Class (BracketCondition(..), bracket, fork, uninterruptible)
import Data.Time.Duration (Milliseconds(..))
import Debug.Trace (traceM)
import Effect (Effect)
import Effect.Aff (delay, killFiber, launchAff_)
import Effect.Class (liftEffect)
import Effect.Class.Console as Console
import Effect.Exception (error)
atomic action postAction =
bracket (pure unit) (\a b ->
case a of
Completed x ->
postAction
Failed e ->
traceM "failed"
Killed e ->
traceM "killed"
) (\_-> action)
main :: Effect Unit
main = do
launchAff_ do
fiber <- fork do
atomic
(uninterruptible do
delay $ 15.0 # Milliseconds
liftEffect $ Console.log "hi"
)
(liftEffect $ Console.log "here")
delay $ 10.0 # Milliseconds
killFiber (error "asdf") fiberThe above code only traces "killed", although it should most likely have run the postAction handler, thus printing "here" to the console.
Metadata
Metadata
Assignees
Labels
No labels