{-# LANGUAGE CPP, UnicodeSyntax, NoImplicitPrelude, FlexibleContexts #-}--------------------------------------------------------------------------------- |-- Module : System.Timeout.Lifted-- Copyright : (c) The University of Glasgow 2007-- License : BSD-style (see the file libraries/base/LICENSE)---- Maintainer : libraries@haskell.org-- Stability : experimental-- Portability : non-portable---- Attach a timeout event to monadic computations-- which are instances of 'MonadBaseControl'.---------------------------------------------------------------------------------moduleSystem.Timeout.Lifted(timeout)where-- from base:importData.Int(Int)importData.Maybe(Maybe(Nothing,Just),maybe)importControl.Monad((>>=),return,liftM)importSystem.IO(IO)importqualifiedSystem.TimeoutasT(timeout)-- from base-unicode-symbols:importData.Function.Unicode((∘))-- from monad-control:importControl.Monad.Trans.Control(MonadBaseControl,restoreM,liftBaseWith)#include "inlinable.h"-- | Generalized version of 'T.timeout'.---- Note that when the given computation times out any side effects of @m@ are-- discarded. When the computation completes within the given time the-- side-effects are restored on return.timeout∷MonadBaseControlIOm⇒Int→ma→m(Maybea)timeouttm=liftBaseWith(\runInIO→T.timeoutt(runInIOm))>>=maybe(returnNothing)(liftMJust∘restoreM){-# INLINABLE timeout #-}