packages feed

STMonadTrans 0.4.5 → 0.4.6

raw patch · 5 files changed

+107/−77 lines, 5 filesdep ~basedep ~transformersnew-uploaderPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: base, transformers

API changes (from Hackage documentation)

- Control.Monad.ST.Trans.Internal: instance Control.Monad.Error.Class.MonadError e m => Control.Monad.Error.Class.MonadError e (Control.Monad.ST.Trans.Internal.STT s m)
- Control.Monad.ST.Trans.Internal: instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (Control.Monad.ST.Trans.Internal.STT s m)
- Control.Monad.ST.Trans.Internal: instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (Control.Monad.ST.Trans.Internal.STT s m)
- Control.Monad.ST.Trans.Internal: instance Control.Monad.Reader.Class.MonadReader r m => Control.Monad.Reader.Class.MonadReader r (Control.Monad.ST.Trans.Internal.STT s m)
- Control.Monad.ST.Trans.Internal: instance Control.Monad.State.Class.MonadState s m => Control.Monad.State.Class.MonadState s (Control.Monad.ST.Trans.Internal.STT s' m)
- Control.Monad.ST.Trans.Internal: instance Control.Monad.Writer.Class.MonadWriter w m => Control.Monad.Writer.Class.MonadWriter w (Control.Monad.ST.Trans.Internal.STT s m)
- Control.Monad.ST.Trans.Internal: instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.ST.Trans.Internal.STT s m)
+ Control.Monad.ST.Trans.Internal: instance (Control.Monad.Error.Class.MonadError e m, GHC.Base.Functor m) => Control.Monad.Error.Class.MonadError e (Control.Monad.ST.Trans.Internal.STT s m)
+ Control.Monad.ST.Trans.Internal: instance (Control.Monad.Fail.MonadFail m, GHC.Base.Functor m) => Control.Monad.Fail.MonadFail (Control.Monad.ST.Trans.Internal.STT s m)
+ Control.Monad.ST.Trans.Internal: instance (Control.Monad.Fix.MonadFix m, GHC.Base.Functor m) => Control.Monad.Fix.MonadFix (Control.Monad.ST.Trans.Internal.STT s m)
+ Control.Monad.ST.Trans.Internal: instance (Control.Monad.Reader.Class.MonadReader r m, GHC.Base.Functor m) => Control.Monad.Reader.Class.MonadReader r (Control.Monad.ST.Trans.Internal.STT s m)
+ Control.Monad.ST.Trans.Internal: instance (Control.Monad.State.Class.MonadState s m, GHC.Base.Functor m) => Control.Monad.State.Class.MonadState s (Control.Monad.ST.Trans.Internal.STT s1 m)
+ Control.Monad.ST.Trans.Internal: instance (Control.Monad.Writer.Class.MonadWriter w m, GHC.Base.Functor m) => Control.Monad.Writer.Class.MonadWriter w (Control.Monad.ST.Trans.Internal.STT s m)
+ Control.Monad.ST.Trans.Internal: instance (GHC.Base.Monad m, GHC.Base.Functor m) => GHC.Base.Monad (Control.Monad.ST.Trans.Internal.STT s m)
- Control.Monad.ST.Trans: unsafeIOToSTT :: Monad m => IO a -> STT s m a
+ Control.Monad.ST.Trans: unsafeIOToSTT :: (Monad m, Functor m) => IO a -> STT s m a

Files

Control/Monad/ST/Trans.hs view
@@ -4,19 +4,19 @@    Copyright   :  Josef Svenningsson 2008-2017                   (c) The University of Glasgow, 1994-2000    License     :  BSD- -   Maintainer  :  josef.svenningsson@gmail.com-   Stability   :  experimental++   Maintainer  :  josef.svenningsson@gmail.com, Andreas Abel+   Stability   :  stable    Portability :  non-portable (GHC Extensions)     This library provides a monad transformer version of the ST monad.     Warning! This monad transformer should not be used with monads that-   can contain multiple answers, like the list monad. The reason is that +   can contain multiple answers, like the list monad. The reason is that    the state token will be duplicated across the different answers and    this causes 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.+   transparency). Safe monads include the monads @'State'@, @'Reader'@, @'Writer'@,+   @'Maybe'@ and combinations of their corresponding monad transformers.  -} module Control.Monad.ST.Trans(@@ -49,28 +49,25 @@       unsafeSTTToIO,       unsafeSTRefToIORef,       unsafeIORefToSTRef-      )where+      ) where -import GHC.Base-import GHC.Arr (Ix(..), Array(..))+import GHC.Base            (realWorld#)+import GHC.Arr             (Ix, Array(..)) import qualified GHC.Arr as STArray -import Data.STRef (STRef)-import qualified Data.STRef as STRef--import Data.Array.ST hiding (runSTArray)---import qualified Data.Array.ST as STArray- #if __GLASGOW_HASKELL__ <= 708-import Control.Applicative+import Control.Applicative (Applicative) #endif  import Control.Monad.ST.Trans.Internal -import Data.IORef+import Data.Array.ST       (STArray, newArray, readArray, writeArray)+import Data.IORef          (IORef)+import Data.STRef          (STRef)+import qualified Data.STRef as STRef -import Unsafe.Coerce-import System.IO.Unsafe+import System.IO.Unsafe    (unsafePerformIO)+import Unsafe.Coerce       (unsafeCoerce)  {-# INLINE newSTRef #-} -- | Create a new reference@@ -92,7 +89,7 @@ -- | Executes a computation in the 'STT' monad transformer runST :: Monad m => (forall s. STT s m a) -> m a runST m = let (STT f) = m- -- the parenthesis is needed because of a bug in GHC's parser+ -- the parenthesis is needed because of a bug in the parser of GHC           in do (STTRet _st a) <- ( f realWorld# )                 return a @@ -206,8 +203,8 @@ runSTArray st = runSTT (st >>= unsafeFreezeSTArray)  -{-# NOINLINE unsafeIOToSTT #-} -unsafeIOToSTT :: (Monad m) => IO a -> STT s m a+{-# NOINLINE unsafeIOToSTT #-}+unsafeIOToSTT :: (Monad m, Functor m) => IO a -> STT s m a unsafeIOToSTT m = return $! unsafePerformIO m  {-# DEPRECATED unsafeSTToIO "Use unsafeSTTToIO instead" #-}
Control/Monad/ST/Trans/Internal.hs view
@@ -5,20 +5,20 @@    Copyright   :  Josef Svenningsson 2008-2010                   (c) The University of Glasgow, 1994-2000    License     :  BSD- -   Maintainer  :  josef.svenningsson@gmail.com-   Stability   :  experimental++   Maintainer  :  josef.svenningsson@gmail.com, Andreas Abel+   Stability   :  stable    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+   occasions where it is 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 +   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 +   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@@ -40,8 +40,8 @@  import Data.Array.ST import Data.Array.Base-import GHC.Int    (      Int8,  Int16,  Int32,  Int64)-import GHC.Word   (Word, Word8, Word16, Word32, Word64)+import GHC.Int    (Int8,  Int16,  Int32,  Int64)+import GHC.Word   (Word8, Word16, Word32, Word64) import GHC.Ptr    (Ptr, FunPtr) import GHC.Stable (StablePtr) @@ -59,32 +59,32 @@ -- | Lifting the `ST` monad into `STT`. The library uses this function --   extensively to be able to reuse functions from `ST`. liftST :: Applicative m => ST s a -> STT s m a-liftST (ST f) = STT (\s -> let (# s', a #) = f s in pure (STTRet s' a))+liftST (ST f) = STT (\s -> let !(# s', a #) = f s in pure (STTRet s' a)) {-# INLINE liftST #-}  -- All instances have to go in this module because otherwise they -- would be orphan instances. -instance Monad m => Monad (STT s m) where-  return a = STT $ \st -> return (STTRet st a)-  STT m >>= k = STT $ \st -> +instance (Monad m, Functor m) => Monad (STT s m) where+  return = pure+  STT m >>= k = STT $ \st ->     do ret <- m st        case ret of-         STTRet new_st a -> +         STTRet new_st a ->              unSTT (k a) new_st -instance MF.MonadFail m => MF.MonadFail (STT s m) where+instance (MF.MonadFail m, Functor m) => MF.MonadFail (STT s m) where   fail msg = lift (fail msg)  instance MonadTrans (STT s) where   lift m = STT $ \st ->    do a <- m       return (STTRet st a)-      + liftSTT :: STT s m a -> State# s -> m (STTRet s a) liftSTT (STT m) s = m s -instance (MonadFix m) => MonadFix (STT s m) where+instance (MonadFix m, Functor m) => MonadFix (STT s m) where   mfix k = STT $ \ s -> mdo     ans@(STTRet _ r) <- liftSTT (k r) s     return ans@@ -104,20 +104,20 @@  -- Instances of other monad classes -instance MonadError e m => MonadError e (STT s m) where+instance (MonadError e m, Functor m) => MonadError e (STT s m) where   throwError e = lift (throwError e)-  catchError (STT m) f = STT $ \st -> catchError (m st) +  catchError (STT m) f = STT $ \st -> catchError (m st)                          (\e -> unSTT (f e) st) -instance MonadReader r m => MonadReader r (STT s m) where+instance (MonadReader r m, Functor m) => MonadReader r (STT s m) where   ask = lift ask   local f (STT m) = STT $ \st -> local f (m st) -instance MonadState s m => MonadState s (STT s' m) where+instance (MonadState s m, Functor m) => MonadState s (STT s1 m) where   get = lift get   put s = lift (put s) -instance MonadWriter w m => MonadWriter w (STT s m) where+instance (MonadWriter w m, Functor m) => MonadWriter w (STT s m) where   tell w = lift (tell w)   listen (STT m)= STT $ \st1 -> do (STTRet st2 a, w) <- listen (m st1)                                    return (STTRet st2 (a,w))@@ -409,4 +409,3 @@     unsafeRead arr i = liftST (unsafeRead arr i)     {-# INLINE unsafeWrite #-}     unsafeWrite arr i e = liftST (unsafeWrite arr i e)-
+ README.md view
@@ -0,0 +1,15 @@+# STMonadTrans++[![Hackage](https://img.shields.io/hackage/v/STMonadTrans.svg?label=Hackage&color=informational)](https://hackage.haskell.org/package/STMonadTrans)+[![STMonadTrans on Stackage Nightly](https://stackage.org/package/STMonadTrans/badge/nightly)](https://stackage.org/nightly/package/STMonadTrans)+[![Stackage](https://www.stackage.org/package/STMonadTrans/badge/lts?label=Stackage)](https://www.stackage.org/package/STMonadTrans)+[![Build Status](https://github.com/josefs/STMonadTrans/workflows/Haskell-CI/badge.svg)](https://github.com/josefs/STMonadTrans/actions)++A monad transformer version of the [ST monad](https://hackage.haskell.org/package/base/docs/Control-Monad-ST.html).++Warning! This monad transformer should not be used with monads that+can contain multiple answers, like the list monad. The reason is that+the state token will be duplicated across the different answers and+this causes 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.
STMonadTrans.cabal view
@@ -1,16 +1,18 @@ name:		STMonadTrans-version:	0.4.5+version:	0.4.6 cabal-version:  >= 1.10 license:	BSD3 license-file:	LICENSE author:		Josef Svenningsson-maintainer:	josef.svenningsson@gmail.com+maintainer:	josef.svenningsson@gmail.com, Andreas Abel+homepage:       https://github.com/josefs/STMonadTrans+bug-reports:    https://github.com/josefs/STMonadTrans/issues category:	Monads build-type:	Simple synopsis:	A monad transformer version of the ST monad description:-   A monad transformer version of the ST monad-+   A monad transformer version of the ST monad.+   .    Warning! This monad transformer should not be used with monads that    can contain multiple answers, like the list monad. The reason is that    the state token will be duplicated across the different answers and@@ -26,38 +28,48 @@            , GHC == 8.4.4            , GHC == 8.6.5            , GHC == 8.8.4-           , GHC == 8.10.3+           , GHC == 8.10.4+           , GHC == 9.0.1  extra-source-files:-        changelog.md+  README.md+  changelog.md  source-repository head   type:     git   location: https://github.com/josefs/STMonadTrans -flag splitBase-  description: Choose the new smaller, split-up base package.- library   default-language: Haskell2010-  build-depends: base >= 4.6--  if flag(splitBase)-    build-depends: base >= 3, base < 5, mtl >= 1.1, array-  else-    build-depends: base < 3+  build-depends:    base    >= 4.6 && < 5+                  , mtl     >= 1.1+                  , array +  -- MonadFail for GHC <= 7   if impl(ghc < 8.0)-    build-depends: fail+    build-depends:  fail    exposed-modules:-    Control.Monad.ST.Trans,+    Control.Monad.ST.Trans     Control.Monad.ST.Trans.Internal-  default-extensions: CPP, MagicHash, UnboxedTuples, Rank2Types,-                FlexibleInstances,-                MultiParamTypeClasses, UndecidableInstances -  ghc-options: -Wall -fwarn-tabs+  default-extensions:+    CPP+    BangPatterns+    MagicHash+    UnboxedTuples+    Rank2Types+    FlexibleInstances+    MultiParamTypeClasses+    UndecidableInstances++  ghc-options:+    -Wall+    -fwarn-tabs++  if impl(ghc >= 8.0)+    ghc-options:+      -Wcompat  test-suite test   default-language: Haskell2010
changelog.md view
@@ -1,7 +1,14 @@+0.4.6++  * Warning-free for all supported GHC versions (7.6 -- 9.2).+  * Drop `splitBase` cabal flag (`base >= 4` is already assumed).+  * Include `README.md` in distributed tarball.+  * Added maintainer Andreas Abel.+ 0.4.5 -  * Don't use default class methods in any MArray (STUArray s) instance. Thanks to Henri Jones-  * Allow tasty up to and including 1.4+  * Don't use default class methods in any `MArray (STUArray s)` instance. Thanks to Henri Jones.+  * Allow `tasty` up to and including 1.4.  0.4.4 @@ -11,21 +18,21 @@ 0.4.3    * Fix compilation for GHC 7.6.3. Thanks to Andrés Sicard-Ramírez.-  * Export unsafe array operations+  * Export unsafe array operations.  0.4.2 -  * Deprecate runST and unsafeSTToIO in favor of-    runSTT and unsafeSTTToIO.-  * Added INLINE pragmas+  * Deprecate `runST` and `unsafeSTToIO` in favor of+    `runSTT` and `unsafeSTTToIO`.+  * Added `INLINE` pragmas.  0.4.1 -  * Add Applicative constraints to be compatible with GHC 7.8.4-  * Add changelog+  * Add `Applicative` constraints to be compatible with GHC 7.8.4.+  * Add changelog.  0.4 -  * New library structure, based on liftST. It reuses more code and-    types from the standard ST monad. Thanks to @wyager for liftST.-  * Instances for MArray+  * New library structure, based on `liftST`. It reuses more code and+    types from the standard `ST` monad. Thanks to @wyager for `liftST`.+  * Instances for `MArray`.