on master help sign in
primitive patch haskell/primitive#11
commitfb85a3c7d205ffc4e59543971c98d47452c3dd58 authorMichael Snoyman <michael@snoyman.com> dateFri 1 Aug 2014, 14:50 (12 years ago) parent73cde7e
1 file changed+62
patching/patches/primitive-0.5.3.0.patch+62
patching/patches/primitive-0.5.3.0.patchnew file+62
@@ -0,0 +1,62 @@
1+diff -ruN orig/Control/Monad/Primitive.hs new/Control/Monad/Primitive.hs
2+--- orig/Control/Monad/Primitive.hs 2014-08-01 14:49:04.175318972 +0300
3++++ new/Control/Monad/Primitive.hs 2014-08-01 14:49:03.000000000 +0300
4+@@ -44,7 +44,9 @@
5+ primitive_ :: PrimMonad m
6+ => (State# (PrimState m) -> State# (PrimState m)) -> m ()
7+ {-# INLINE primitive_ #-}
8+-primitive_ f = primitive (\s# -> (# f s#, () #))
9++primitive_ f = primitive (\s# ->
10++ case f s# of
11++ s'# -> (# s'#, () #))
12+
13+ instance PrimMonad IO where
14+ type PrimState IO = RealWorld
15+diff -ruN orig/primitive.cabal new/primitive.cabal
16+--- orig/primitive.cabal 2014-08-01 14:49:04.175318972 +0300
17++++ new/primitive.cabal 2014-08-01 14:49:03.000000000 +0300
18+@@ -50,6 +50,16 @@
19+ if arch(i386) || arch(x86_64)
20+ cc-options: -msse2
21+
22++test-suite test
23++ Default-Language: Haskell2010
24++ hs-source-dirs: test
25++ main-is: main.hs
26++ type: exitcode-stdio-1.0
27++ build-depends: base
28++ , ghc-prim
29++ , primitive
30++ ghc-options: -O2
31++
32+ source-repository head
33+ type: git
34+ location: https://github.com/haskell/primitive
35+diff -ruN orig/test/main.hs new/test/main.hs
36+--- orig/test/main.hs 1970-01-01 02:00:00.000000000 +0200
37++++ new/test/main.hs 2014-08-01 14:49:03.000000000 +0300
38+@@ -0,0 +1,24 @@
39++{-# LANGUAGE MagicHash, UnboxedTuples #-}
40++import Control.Monad.Primitive
41++import Data.Primitive.Array
42++import GHC.IO
43++import GHC.Prim
44++
45++-- Since we only have a single test case right now, I'm going to avoid the
46++-- issue of choosing a test framework for the moment. This also keeps the
47++-- package as a whole light on dependencies.
48++
49++main :: IO ()
50++main = do
51++ arr <- newArray 1 'A'
52++ let unit =
53++ case writeArray arr 0 'B' of
54++ IO f ->
55++ case f realWorld# of
56++ _ -> ()
57++ c1 <- readArray arr 0
58++ return $! unit
59++ c2 <- readArray arr 0
60++ if c1 == 'A' && c2 == 'B'
61++ then return ()
62++ else error $ "Expected AB, got: " ++ show (c1, c2)