System/Environment.hs System/Exit.hs \
System/Mem.hs System/Info.hs \
System/Console/GetOpt.hs \
- System/CPUTime.hsc \
+ System/CPUTime.hsc System/Timeout.hs \
Foreign/Ptr.hs Foreign/StablePtr.hs Foreign/Storable.hs \
Foreign/ForeignPtr.hs Foreign/C/Types.hs \
Foreign/Marshal/Alloc.hs Foreign/Marshal/Array.hs \
module System.Timeout ( timeout ) where
+#if __NHC__
+timeout :: Int -> IO a -> IO (Maybe a)
+timeout n f = fmap Just f
+#else
+
import Prelude (IO, Ord((<)), Eq((==)), Int, (.), otherwise, fmap)
import Data.Maybe (Maybe(..))
import Control.Monad (Monad(..), guard)
(bracket (forkIO (threadDelay n >> throwDynTo pid ex))
(killThread)
(\_ -> fmap Just f))
+#endif