projects
/
ghc-base.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[project @ 2002-05-09 13:16:29 by simonmar]
[ghc-base.git]
/
Control
/
Monad
/
ST.hs
diff --git
a/Control/Monad/ST.hs
b/Control/Monad/ST.hs
index
6cbae95
..
2a3985a
100644
(file)
--- a/
Control/Monad/ST.hs
+++ b/
Control/Monad/ST.hs
@@
-1,14
+1,12
@@
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
---
+-- |
-- Module : Control.Monad.ST
-- Copyright : (c) The University of Glasgow 2001
-- Module : Control.Monad.ST
-- Copyright : (c) The University of Glasgow 2001
--- License : BSD-style (see the file libraries/core/LICENSE)
+-- License : BSD-style (see the file libraries/base/LICENSE)
--
-- Maintainer : libraries@haskell.org
-- Stability : experimental
--
-- Maintainer : libraries@haskell.org
-- Stability : experimental
--- Portability : non-portable
---
--- $Id: ST.hs,v 1.1 2001/06/28 14:15:02 simonmar Exp $
+-- Portability : non-portable (requires universal quantification for runST)
--
-- The State Transformer Monad, ST
--
--
-- The State Transformer Monad, ST
--
@@
-29,19
+27,24
@@
module Control.Monad.ST
import Prelude
import Prelude
+import Control.Monad.Fix
import Data.Dynamic
#ifdef __GLASGOW_HASKELL__
import GHC.ST
import Data.Dynamic
#ifdef __GLASGOW_HASKELL__
import GHC.ST
-import GHC.Prim ( unsafeCoerce#, RealWorld )
+import GHC.Base ( unsafeCoerce#, RealWorld )
import GHC.IOBase ( IO(..), stToIO )
import GHC.IOBase ( IO(..), stToIO )
+-- This relies on IO and ST having the same representation modulo the
+-- constraint on the type of the state
+--
unsafeIOToST :: IO a -> ST s a
unsafeIOToST :: IO a -> ST s a
-unsafeIOToST (IO io) = ST $ \ s ->
- case ((unsafeCoerce# io) s) of
- (# new_s, a #) -> unsafeCoerce# (STret new_s a)
+unsafeIOToST (IO io) = ST $ \ s -> (unsafeCoerce# io) s
#endif
#endif
+instance MonadFix (ST s) where
+ mfix = fixST
+
-- ---------------------------------------------------------------------------
-- Typeable instance
-- ---------------------------------------------------------------------------
-- Typeable instance