moduleSystem.Timeout.Monad(timeoutR,timeoutM,timeoutVoid)whereimportControl.Monad.IO.ClassimportControl.Monad.RunnableimportSystem.Timeout-- | Run an action that is runnable in the IO monad within a time limit---- The time limit is specified in microseconds, and is subject to the same sas 'System.Timeout.timeout'. -- Finally, the action to be run itself is passed. The result is an IO action, which is-- normally lifted with 'liftIO' to be run in the same IO (see 'timeoutM'). The action,-- when run, returns the resulting monadic value if it was run in time. Conceptually,-- one can think of this as running a local monad, perhaps a copy, in the IO monad;-- the effects of running in the IO monad are unavoidably irreversible, but the resulting monadic-- value can be optionally ignored, in which case it is not evaluated in the parent monad-- and no effects are present in the outer layers of the monad.timeoutR::(Integrali,Monadm,MonadRunnablem)=>i->ma->RunDatam->IO(Maybe(ma))timeoutRimd=doc<-timeout(fromIntegrali).rcToIO$runmdcasecof(Justc')->doreturn.Just$constructc'(Nothing)->doreturn$Nothing-- | Equivalent to 'timeoutM', but the result is the same monad, making passing the data needed to run the monad unnecessarytimeoutM::(Integrali,Monadm,MonadIOm,MonadRunnablem)=>i->ma->m(Maybe(ma))timeoutMim=liftIO.timeoutRim=<<runData-- | If the void action runs in time, it is run and 'True' is returned; otherwise 'False' is returned when running the action in time does not succeed---- For example, to run a void action within one second,-- one might write---- > succeeded <- timeoutVoid---- The effects of "action" will be fully executed if succeeded-- is 'True'; if succeeded is 'False', the action could not run-- in time, and only global IO actions that were performed while-- the local monad was being evaluated will be run.timeoutVoid::(Integrali,Monadm,MonadIOm,MonadRunnablem)=>i->m()->mBooltimeoutVoidim=maybe(returnFalse)(>>returnTrue)=<<timeoutMim