Hello community, here is the log from the commit of package ghc-primitive for openSUSE:Factory checked in at 2015-05-13 07:13:07 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-primitive (Old) and /work/SRC/openSUSE:Factory/.ghc-primitive.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-primitive" Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-primitive/ghc-primitive.changes 2014-11-26 20:55:02.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.ghc-primitive.new/ghc-primitive.changes 2015-05-13 07:13:08.000000000 +0200 @@ -1,0 +2,14 @@ +Thu Apr 9 18:17:22 UTC 2015 - [email protected] + +- update to 0.6 + + Split PrimMonad into two classes to allow automatic lifting of primitive + operations into monad transformers. The internal operation has moved + to the PrimBase class. + + Fixed the test suite on older GHCs + + Changed primitive_ to work around an oddity with GHC's code generation on + certain versions that led to side effects not happening when used in + conjunction with certain very unsafe IO performers. + + Allow primitive to build on GHC 7.9 + + Implement cloneArray and cloneMutableArray primitives + (with fall-back implementations for GHCs prior to version 7.2.1) +------------------------------------------------------------------- Old: ---- primitive-0.5.2.1.tar.gz New: ---- primitive-0.6.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-primitive.spec ++++++ --- /var/tmp/diff_new_pack.qvmyaf/_old 2015-05-13 07:13:09.000000000 +0200 +++ /var/tmp/diff_new_pack.qvmyaf/_new 2015-05-13 07:13:09.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package ghc-primitive # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %global pkg_name primitive Name: ghc-primitive -Version: 0.5.2.1 +Version: 0.6 Release: 0 Summary: Primitive memory-related operations License: BSD-3-Clause @@ -31,11 +31,11 @@ BuildRequires: ghc-Cabal-devel BuildRequires: ghc-rpm-macros +BuildRequires: ghc-transformers-devel %description This package provides various primitive memory-related operations. - %package devel Summary: Haskell %{pkg_name} library development files Group: Development/Libraries/Other ++++++ primitive-0.5.2.1.tar.gz -> primitive-0.6.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/primitive-0.5.2.1/Control/Monad/Primitive.hs new/primitive-0.6/Control/Monad/Primitive.hs --- old/primitive-0.5.2.1/Control/Monad/Primitive.hs 2014-02-19 20:25:03.000000000 +0100 +++ new/primitive-0.6/Control/Monad/Primitive.hs 2015-03-28 02:10:00.000000000 +0100 @@ -1,4 +1,5 @@ {-# LANGUAGE CPP, MagicHash, UnboxedTuples, TypeFamilies #-} +{-# LANGUAGE FlexibleContexts, FlexibleInstances, UndecidableInstances #-} -- | -- Module : Control.Monad.Primitive @@ -13,7 +14,8 @@ module Control.Monad.Primitive ( PrimMonad(..), RealWorld, primitive_, - primToPrim, primToIO, primToST, + PrimBase(..), + liftPrim, primToPrim, primToIO, primToST, unsafePrimToPrim, unsafePrimToIO, unsafePrimToST, unsafeInlinePrim, unsafeInlineIO, unsafeInlineST, touch @@ -28,7 +30,27 @@ #endif import GHC.ST ( ST(..) ) --- | Class of primitive state-transformer monads +import Control.Monad.Trans.Class (lift) +import Data.Monoid (Monoid) + +import Control.Monad.Trans.Identity ( IdentityT) +import Control.Monad.Trans.List ( ListT ) +import Control.Monad.Trans.Maybe ( MaybeT ) +import Control.Monad.Trans.Error ( ErrorT, Error) +import Control.Monad.Trans.Reader ( ReaderT ) +import Control.Monad.Trans.State ( StateT ) +import Control.Monad.Trans.Writer ( WriterT ) +import Control.Monad.Trans.RWS ( RWST ) + +#if MIN_VERSION_transformers(0,4,0) +import Control.Monad.Trans.Except ( ExceptT ) +#endif + +import qualified Control.Monad.Trans.RWS.Strict as Strict ( RWST ) +import qualified Control.Monad.Trans.State.Strict as Strict ( StateT ) +import qualified Control.Monad.Trans.Writer.Strict as Strict ( WriterT ) + +-- | Class of monads which can perform primitive state-transformer actions class Monad m => PrimMonad m where -- | State token type type PrimState m @@ -36,7 +58,12 @@ -- | Execute a primitive operation primitive :: (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a - +-- | Class of primitive monads for state-transformer actions. +-- +-- Unlike 'PrimMonad', this typeclass requires that the @Monad@ be fully +-- expressed as a state transformer, therefore disallowing other monad +-- transformers on top of the base @IO@ or @ST@. +class PrimMonad m => PrimBase m where -- | Expose the internal structure of the monad internal :: m a -> State# (PrimState m) -> (# State# (PrimState m), a #) @@ -44,56 +71,120 @@ primitive_ :: PrimMonad m => (State# (PrimState m) -> State# (PrimState m)) -> m () {-# INLINE primitive_ #-} -primitive_ f = primitive (\s# -> (# f s#, () #)) +primitive_ f = primitive (\s# -> + case f s# of + s'# -> (# s'#, () #)) instance PrimMonad IO where type PrimState IO = RealWorld primitive = IO - internal (IO p) = p {-# INLINE primitive #-} +instance PrimBase IO where + internal (IO p) = p {-# INLINE internal #-} +instance PrimMonad m => PrimMonad (IdentityT m) where + type PrimState (IdentityT m) = PrimState m + primitive = lift . primitive + {-# INLINE primitive #-} +instance PrimMonad m => PrimMonad (ListT m) where + type PrimState (ListT m) = PrimState m + primitive = lift . primitive + {-# INLINE primitive #-} +instance PrimMonad m => PrimMonad (MaybeT m) where + type PrimState (MaybeT m) = PrimState m + primitive = lift . primitive + {-# INLINE primitive #-} +instance (Error e, PrimMonad m) => PrimMonad (ErrorT e m) where + type PrimState (ErrorT e m) = PrimState m + primitive = lift . primitive + {-# INLINE primitive #-} +instance PrimMonad m => PrimMonad (ReaderT r m) where + type PrimState (ReaderT r m) = PrimState m + primitive = lift . primitive + {-# INLINE primitive #-} +instance PrimMonad m => PrimMonad (StateT s m) where + type PrimState (StateT s m) = PrimState m + primitive = lift . primitive + {-# INLINE primitive #-} +instance (Monoid w, PrimMonad m) => PrimMonad (WriterT w m) where + type PrimState (WriterT w m) = PrimState m + primitive = lift . primitive + {-# INLINE primitive #-} +instance (Monoid w, PrimMonad m) => PrimMonad (RWST r w s m) where + type PrimState (RWST r w s m) = PrimState m + primitive = lift . primitive + {-# INLINE primitive #-} + +#if MIN_VERSION_transformers(0,4,0) +instance PrimMonad m => PrimMonad (ExceptT e m) where + type PrimState (ExceptT e m) = PrimState m + primitive = lift . primitive + {-# INLINE primitive #-} +#endif + +instance PrimMonad m => PrimMonad (Strict.StateT s m) where + type PrimState (Strict.StateT s m) = PrimState m + primitive = lift . primitive + {-# INLINE primitive #-} +instance (Monoid w, PrimMonad m) => PrimMonad (Strict.WriterT w m) where + type PrimState (Strict.WriterT w m) = PrimState m + primitive = lift . primitive + {-# INLINE primitive #-} +instance (Monoid w, PrimMonad m) => PrimMonad (Strict.RWST r w s m) where + type PrimState (Strict.RWST r w s m) = PrimState m + primitive = lift . primitive + {-# INLINE primitive #-} + instance PrimMonad (ST s) where type PrimState (ST s) = s primitive = ST - internal (ST p) = p {-# INLINE primitive #-} +instance PrimBase (ST s) where + internal (ST p) = p {-# INLINE internal #-} --- | Convert a 'PrimMonad' to another monad with the same state token. -primToPrim :: (PrimMonad m1, PrimMonad m2, PrimState m1 ~ PrimState m2) +-- | Lifts a 'PrimBase' into another 'PrimMonad' with the same underlying state +-- token type. +liftPrim + :: (PrimBase m1, PrimMonad m2, PrimState m1 ~ PrimState m2) => m1 a -> m2 a +{-# INLINE liftPrim #-} +liftPrim = primToPrim + +-- | Convert a 'PrimBase' to another monad with the same state token. +primToPrim :: (PrimBase m1, PrimMonad m2, PrimState m1 ~ PrimState m2) => m1 a -> m2 a {-# INLINE primToPrim #-} primToPrim m = primitive (internal m) --- | Convert a 'PrimMonad' with a 'RealWorld' state token to 'IO' -primToIO :: (PrimMonad m, PrimState m ~ RealWorld) => m a -> IO a +-- | Convert a 'PrimBase' with a 'RealWorld' state token to 'IO' +primToIO :: (PrimBase m, PrimState m ~ RealWorld) => m a -> IO a {-# INLINE primToIO #-} primToIO = primToPrim --- | Convert a 'PrimMonad' to 'ST' -primToST :: PrimMonad m => m a -> ST (PrimState m) a +-- | Convert a 'PrimBase' to 'ST' +primToST :: PrimBase m => m a -> ST (PrimState m) a {-# INLINE primToST #-} primToST = primToPrim --- | Convert a 'PrimMonad' to another monad with a possibly different state +-- | Convert a 'PrimBase' to another monad with a possibly different state -- token. This operation is highly unsafe! -unsafePrimToPrim :: (PrimMonad m1, PrimMonad m2) => m1 a -> m2 a +unsafePrimToPrim :: (PrimBase m1, PrimMonad m2) => m1 a -> m2 a {-# INLINE unsafePrimToPrim #-} unsafePrimToPrim m = primitive (unsafeCoerce# (internal m)) --- | Convert any 'PrimMonad' to 'ST' with an arbitrary state token. This +-- | Convert any 'PrimBase' to 'ST' with an arbitrary state token. This -- operation is highly unsafe! -unsafePrimToST :: PrimMonad m => m a -> ST s a +unsafePrimToST :: PrimBase m => m a -> ST s a {-# INLINE unsafePrimToST #-} unsafePrimToST = unsafePrimToPrim --- | Convert any 'PrimMonad' to 'IO'. This operation is highly unsafe! -unsafePrimToIO :: PrimMonad m => m a -> IO a +-- | Convert any 'PrimBase' to 'IO'. This operation is highly unsafe! +unsafePrimToIO :: PrimBase m => m a -> IO a {-# INLINE unsafePrimToIO #-} unsafePrimToIO = unsafePrimToPrim -unsafeInlinePrim :: PrimMonad m => m a -> a +unsafeInlinePrim :: PrimBase m => m a -> a {-# INLINE unsafeInlinePrim #-} unsafeInlinePrim m = unsafeInlineIO (unsafePrimToIO m) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/primitive-0.5.2.1/Data/Primitive/Array.hs new/primitive-0.6/Data/Primitive/Array.hs --- old/primitive-0.5.2.1/Data/Primitive/Array.hs 2014-02-19 20:25:03.000000000 +0100 +++ new/primitive-0.6/Data/Primitive/Array.hs 2015-03-28 02:10:00.000000000 +0100 @@ -16,7 +16,8 @@ newArray, readArray, writeArray, indexArray, indexArrayM, unsafeFreezeArray, unsafeThawArray, sameMutableArray, - copyArray, copyMutableArray + copyArray, copyMutableArray, + cloneArray, cloneMutableArray ) where import Control.Monad.Primitive @@ -28,6 +29,10 @@ import Data.Data ( Data(..) ) import Data.Primitive.Internal.Compat ( isTrue#, mkNoRepType ) +#if !(__GLASGOW_HASKELL__ >= 702) +import Control.Monad.ST(runST) +#endif + -- | Boxed arrays data Array a = Array (Array# a) deriving ( Typeable ) @@ -156,6 +161,49 @@ | otherwise = return () #endif +-- | Return a newly allocated Array with the specified subrange of the +-- provided Array. The provided Array should contain the full subrange +-- specified by the two Ints, but this is not checked. +cloneArray :: Array a -- ^ source array + -> Int -- ^ offset into destination array + -> Int -- ^ number of elements to copy + -> Array a +{-# INLINE cloneArray #-} +#if __GLASGOW_HASKELL__ >= 702 +cloneArray (Array arr#) (I# off#) (I# len#) + = case cloneArray# arr# off# len# of arr'# -> Array arr'# +#else +cloneArray arr off len = runST $ do + marr2 <- newArray len (error "Undefined element") + copyArray marr2 0 arr off len + unsafeFreezeArray marr2 +#endif + +-- | Return a newly allocated MutableArray. with the specified subrange of +-- the provided MutableArray. The provided MutableArray should contain the +-- full subrange specified by the two Ints, but this is not checked. +cloneMutableArray :: PrimMonad m + => MutableArray (PrimState m) a -- ^ source array + -> Int -- ^ offset into destination array + -> Int -- ^ number of elements to copy + -> m (MutableArray (PrimState m) a) +{-# INLINE cloneMutableArray #-} +#if __GLASGOW_HASKELL__ >= 702 +cloneMutableArray (MutableArray arr#) (I# off#) (I# len#) = primitive + (\s# -> case cloneMutableArray# arr# off# len# s# of + (# s'#, arr'# #) -> (# s'#, MutableArray arr'# #)) +#else +cloneMutableArray marr off len = do + marr2 <- newArray len (error "Undefined element") + let go !i !j c + | c >= len = return marr2 + | otherwise = do + b <- readArray marr i + writeArray marr2 j b + go (i+1) (j+1) (c+1) + go off 0 0 +#endif + instance Typeable a => Data (Array a) where toConstr _ = error "toConstr" gunfold _ _ = error "gunfold" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/primitive-0.5.2.1/changelog new/primitive-0.6/changelog --- old/primitive-0.5.2.1/changelog 2014-02-19 20:25:03.000000000 +0100 +++ new/primitive-0.6/changelog 1970-01-01 01:00:00.000000000 +0100 @@ -1,41 +0,0 @@ -Changes in version 0.5.2.0 - - * Add strict variants of 'MutVar' modification functions - -Changes in version 0.5.1.0 - - * Add support for GHC 7.7's new primitive 'Bool' representation - -Changes in version 0.5.0.1 - - * Disable array copying primitives for GHC 7.6.* and earlier - -Changes in version 0.5 - - * New in "Data.Primitive.MutVar": 'atomicModifyMutVar' - - * Efficient block fill operations: 'setByteArray', 'setAddr' - -Changes in version 0.4.1 - - * New module "Data.Primitive.MutVar" - -Changes in version 0.4.0.1 - - * Critical bug fix in 'fillByteArray' - -Changes in version 0.4 - - * Support for GHC 7.2 array copying primitives - - * New in "Data.Primitive.ByteArray": 'copyByteArray', - 'copyMutableByteArray', 'moveByteArray', 'fillByteArray' - - * Deprecated in "Data.Primitive.ByteArray": 'memcpyByteArray', - 'memcpyByteArray'', 'memmoveByteArray', 'memsetByteArray' - - * New in "Data.Primitive.Array": 'copyArray', 'copyMutableByteArray' - - * New in "Data.Primitive.Addr": 'copyAddr', 'moveAddr' - - * Deprecated in "Data.Primitive.Addr": 'memcpyAddr' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/primitive-0.5.2.1/changelog.md new/primitive-0.6/changelog.md --- old/primitive-0.5.2.1/changelog.md 1970-01-01 01:00:00.000000000 +0100 +++ new/primitive-0.6/changelog.md 2015-03-28 02:10:00.000000000 +0100 @@ -0,0 +1,65 @@ +## Changes in version 0.6 + + * Split PrimMonad into two classes to allow automatic lifting of primitive + operations into monad transformers. The `internal` operation has moved to the + `PrimBase` class. + + * Fixed the test suite on older GHCs + +## Changes in version 0.5.4.0 + + * Changed primitive_ to work around an oddity with GHC's code generation + on certain versions that led to side effects not happening when used + in conjunction with certain very unsafe IO performers. + + * Allow primitive to build on GHC 7.9 + +## Changes in version 0.5.3.0 + + * Implement `cloneArray` and `cloneMutableArray` primitives + (with fall-back implementations for GHCs prior to version 7.2.1) + +## Changes in version 0.5.2.1 + + * Add strict variants of `MutVar` modification functions + `atomicModifyMutVar'` and `modifyMutVar'` + + * Fix compilation on Solaris 10 with GNU C 3.4.3 + +## Changes in version 0.5.1.0 + + * Add support for GHC 7.7's new primitive `Bool` representation + +## Changes in version 0.5.0.1 + + * Disable array copying primitives for GHC 7.6.* and earlier + +## Changes in version 0.5 + + * New in `Data.Primitive.MutVar`: `atomicModifyMutVar` + + * Efficient block fill operations: `setByteArray`, `setAddr` + +## Changes in version 0.4.1 + + * New module `Data.Primitive.MutVar` + +## Changes in version 0.4.0.1 + + * Critical bug fix in `fillByteArray` + +## Changes in version 0.4 + + * Support for GHC 7.2 array copying primitives + + * New in `Data.Primitive.ByteArray`: `copyByteArray`, + `copyMutableByteArray`, `moveByteArray`, `fillByteArray` + + * Deprecated in `Data.Primitive.ByteArray`: `memcpyByteArray`, + `memcpyByteArray'`, `memmoveByteArray`, `memsetByteArray` + + * New in `Data.Primitive.Array`: `copyArray`, `copyMutableByteArray` + + * New in `Data.Primitive.Addr`: `copyAddr`, `moveAddr` + + * Deprecated in `Data.Primitive.Addr`: `memcpyAddr` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/primitive-0.5.2.1/primitive.cabal new/primitive-0.6/primitive.cabal --- old/primitive-0.5.2.1/primitive.cabal 2014-02-19 20:25:03.000000000 +0100 +++ new/primitive-0.6/primitive.cabal 2015-03-28 02:10:00.000000000 +0100 @@ -1,10 +1,10 @@ Name: primitive -Version: 0.5.2.1 +Version: 0.6 License: BSD3 License-File: LICENSE Author: Roman Leshchinskiy <[email protected]> -Maintainer: Roman Leshchinskiy <[email protected]> +Maintainer: [email protected] Copyright: (c) Roman Leshchinskiy 2009-2012 Homepage: https://github.com/haskell/primitive Bug-Reports: https://github.com/haskell/primitive/issues @@ -14,7 +14,7 @@ Build-Type: Simple Description: This package provides various primitive memory-related operations. -Extra-Source-Files: changelog +Extra-Source-Files: changelog.md Library Default-Language: Haskell2010 @@ -36,7 +36,9 @@ Data.Primitive.Internal.Compat Data.Primitive.Internal.Operations - Build-Depends: base >= 4.3 && < 4.8, ghc-prim >= 0.2 && < 0.4 + Build-Depends: base >= 4.3 && < 4.9 + , ghc-prim >= 0.2 && < 0.5 + , transformers >= 0.2 && < 0.5 Ghc-Options: -O2 -Wall @@ -50,6 +52,16 @@ if arch(i386) || arch(x86_64) cc-options: -msse2 +test-suite test + Default-Language: Haskell2010 + hs-source-dirs: test + main-is: main.hs + type: exitcode-stdio-1.0 + build-depends: base + , ghc-prim + , primitive + ghc-options: -O2 + source-repository head type: git location: https://github.com/haskell/primitive diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/primitive-0.5.2.1/test/main.hs new/primitive-0.6/test/main.hs --- old/primitive-0.5.2.1/test/main.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/primitive-0.6/test/main.hs 2015-03-28 02:10:00.000000000 +0100 @@ -0,0 +1,24 @@ +{-# LANGUAGE MagicHash, UnboxedTuples #-} +import Control.Monad.Primitive +import Data.Primitive.Array +import GHC.IO +import GHC.Prim + +-- Since we only have a single test case right now, I'm going to avoid the +-- issue of choosing a test framework for the moment. This also keeps the +-- package as a whole light on dependencies. + +main :: IO () +main = do + arr <- newArray 1 'A' + let unit = + case writeArray arr 0 'B' of + IO f -> + case f realWorld# of + (# _, _ #) -> () + c1 <- readArray arr 0 + return $! unit + c2 <- readArray arr 0 + if c1 == 'A' && c2 == 'B' + then return () + else error $ "Expected AB, got: " ++ show (c1, c2)
