Implement tryAtomicReadMVar.
[packages/base.git] / GHC / GHCi.hs
1 {-# LANGUAGE NoImplicitPrelude #-}
2 {-# OPTIONS_HADDOCK hide #-}
3
4 -----------------------------------------------------------------------------
5 -- |
6 -- Module : GHC.GHCi
7 -- Copyright : (c) The University of Glasgow 2012
8 -- License : see libraries/base/LICENSE
9 --
10 -- Maintainer : cvs-ghc@haskell.org
11 -- Stability : internal
12 -- Portability : non-portable (GHC Extensions)
13 --
14 -- The GHCi Monad lifting interface.
15 --
16 -- EXPERIMENTAL! DON'T USE.
17 --
18 -----------------------------------------------------------------------------
19
20 -- #hide
21 module GHC.GHCi {-# WARNING "This is an unstable interface." #-} (
22 GHCiSandboxIO(..), NoIO()
23 ) where
24
25 import GHC.Base (IO(), Monad, (>>=), return, id, (.))
26
27 -- | A monad that can execute GHCi statements by lifting them out of
28 -- m into the IO monad. (e.g state monads)
29 class (Monad m) => GHCiSandboxIO m where
30 ghciStepIO :: m a -> IO a
31
32 instance GHCiSandboxIO IO where
33 ghciStepIO = id
34
35 -- | A monad that doesn't allow any IO.
36 newtype NoIO a = NoIO { noio :: IO a }
37
38 instance Monad NoIO where
39 return a = NoIO (return a)
40 (>>=) k f = NoIO (noio k >>= noio . f)
41
42 instance GHCiSandboxIO NoIO where
43 ghciStepIO = noio
44