X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=GHC%2FException.lhs;h=0f9223d1ada1ec4d36c2be8fd0bdd16b19642986;hb=bbfa6c16ee53e11ed5a45fed582999c49daa3e88;hp=08f5e97703cdde8c30437676983b8854cfce50fc;hpb=1172e0e4b9640aa96095e31bcdc854cc55b54e34;p=ghc-base.git diff --git a/GHC/Exception.lhs b/GHC/Exception.lhs index 08f5e97..0f9223d 100644 --- a/GHC/Exception.lhs +++ b/GHC/Exception.lhs @@ -1,5 +1,5 @@ \begin{code} -{-# OPTIONS -fno-implicit-prelude #-} +{-# OPTIONS_GHC -fno-implicit-prelude #-} ----------------------------------------------------------------------------- -- | -- Module : GHC.Exception @@ -14,6 +14,7 @@ -- ----------------------------------------------------------------------------- +-- #hide module GHC.Exception ( module GHC.Exception, Exception(..), AsyncException(..), @@ -100,4 +101,18 @@ block (IO io) = IO $ blockAsyncExceptions# io unblock (IO io) = IO $ unblockAsyncExceptions# io \end{code} - +\begin{code} +-- | Forces its argument to be evaluated, and returns the result in +-- the 'IO' monad. It can be used to order evaluation with respect to +-- other 'IO' operations; its semantics are given by +-- +-- > evaluate undefined `seq` return () ==> return () +-- > catch (evaluate undefined) (\e -> return ()) ==> return () +-- +-- NOTE: @(evaluate a)@ is /not/ the same as @(a \`seq\` return a)@. +evaluate :: a -> IO a +evaluate a = IO $ \s -> case a `seq` () of () -> (# s, a #) + -- NB. can't write + -- a `seq` (# s, a #) + -- because we can't have an unboxed tuple as a function argument +\end{code}