Add RULE for "map coerce = map" (#8767)
[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 module GHC.GHCi {-# WARNING "This is an unstable interface." #-} (
21 GHCiSandboxIO(..), NoIO()
22 ) where
23
24 import GHC.Base (IO(), Monad, (>>=), return, id, (.))
25
26 -- | A monad that can execute GHCi statements by lifting them out of
27 -- m into the IO monad. (e.g state monads)
28 class (Monad m) => GHCiSandboxIO m where
29 ghciStepIO :: m a -> IO a
30
31 instance GHCiSandboxIO IO where
32 ghciStepIO = id
33
34 -- | A monad that doesn't allow any IO.
35 newtype NoIO a = NoIO { noio :: IO a }
36
37 instance Monad NoIO where
38 return a = NoIO (return a)
39 (>>=) k f = NoIO (noio k >>= noio . f)
40
41 instance GHCiSandboxIO NoIO where
42 ghciStepIO = noio
43