STMonadTrans 0.2 → 0.3
raw patch · 3 files changed
+44/−10 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Control.Monad.ST.Trans.Internal: STT :: (State# s -> m (STTRet s a)) -> STT s m a
+ Control.Monad.ST.Trans.Internal: STTRet :: (State# s) -> a -> STTRet s a
+ Control.Monad.ST.Trans.Internal: data STTRet s a
+ Control.Monad.ST.Trans.Internal: newtype STT s m a
+ Control.Monad.ST.Trans.Internal: unSTT :: STT s m a -> (State# s -> m (STTRet s a))
Files
Control/Monad/ST/Trans.hs view
@@ -2,7 +2,7 @@ MultiParamTypeClasses, UndecidableInstances, RecursiveDo #-} {- | Module : Control.Monad.ST.Trans- Copyright : Josef Svenningsson 2008+ Copyright : Josef Svenningsson 2008-2010 (c) The University of Glasgow, 1994-2000 License : BSD @@ -50,6 +50,8 @@ import GHC.Arr (Ix(..), safeRangeSize, safeIndex, Array(..), arrEleBottom) +import Control.Monad.ST.Trans.Internal+ import Control.Monad.Fix import Control.Monad.Trans import Control.Monad.Error.Class@@ -63,13 +65,6 @@ import Unsafe.Coerce import System.IO.Unsafe----- | 'STT' is the monad transformer providing polymorphic updateable references-newtype STT s m a = STT (State# s -> m (STTRet s a))-unSTT (STT f) = f--data STTRet s a = STTRet (State# s) a instance Monad m => Monad (STT s m) where return a = STT $ \st -> return (STTRet st a)
+ Control/Monad/ST/Trans/Internal.hs view
@@ -0,0 +1,37 @@+{-# LANGUAGE MagicHash, UnboxedTuples, Rank2Types, FlexibleInstances,+ MultiParamTypeClasses, UndecidableInstances, DoRec #-}+{- |+ Module : Control.Monad.ST.Trans+ Copyright : Josef Svenningsson 2008-2010+ (c) The University of Glasgow, 1994-2000+ License : BSD+ + Maintainer : josef.svenningsson@gmail.com+ Stability : experimental+ Portability : non-portable (GHC Extensions)++ This module provides the implementation of the 'STT' type for those+ occasions where it's needed in order to implement new liftings through+ operations in other monads.++ Warning! This monad transformer should not be used with monads that+ can contain multiple answers, like the list monad. The reason is that + the will be duplicated across the different answers and this cause+ Bad Things to happen (such as loss of referential transparency). Safe + monads include the monads State, Reader, Writer, Maybe and + combinations of their corresponding monad transformers.+-}+module Control.Monad.ST.Trans.Internal where++import GHC.Base++-- | 'STT' is the monad transformer providing polymorphic updateable references+newtype STT s m a = STT (State# s -> m (STTRet s a))++unSTT :: STT s m a -> (State# s -> m (STTRet s a))+unSTT (STT f) = f++-- | 'STTRet' is needed to encapsulate the unboxed state token that GHC passes+-- around. This type is essentially a pair, but an ordinary pair is not+-- not allowed to contain unboxed types.+data STTRet s a = STTRet (State# s) a
STMonadTrans.cabal view
@@ -1,5 +1,5 @@ name: STMonadTrans-version: 0.2+version: 0.3 cabal-version: >= 1.6 license: BSD3 license-file: LICENSE@@ -31,7 +31,9 @@ else build-depends: base < 3 - exposed-modules: Control.Monad.ST.Trans+ exposed-modules: + Control.Monad.ST.Trans,+ Control.Monad.ST.Trans.Internal extensions: MagicHash, UnboxedTuples, Rank2Types, FlexibleInstances, MultiParamTypeClasses, UndecidableInstances