Skip to content

Commit

Permalink
Bump QuickCheck dep and fix redundant constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
benl23x5 committed Oct 15, 2016
1 parent 979e3f8 commit 71ca664
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 47 deletions.
5 changes: 3 additions & 2 deletions repa/Data/Array/Repa/Arbitrary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ instance Arbitrary Z where

-- Note: this is a shape that is "sized", and then random array for a given
-- shape is generated.
instance (Shape a, Arbitrary a) => Arbitrary (a :. Int) where
instance Arbitrary a
=> Arbitrary (a :. Int) where
arbitrary
= sized (\n -> do
b <- choose (1, n)
Expand Down Expand Up @@ -70,7 +71,7 @@ instance (Arbitrary sh, Arbitrary a, Shape sh)
instance CoArbitrary Z where
coarbitrary _ = id

instance (Shape a, CoArbitrary a)
instance (CoArbitrary a)
=> CoArbitrary (a :. Int) where
coarbitrary (a :. b) = coarbitrary a . coarbitrary b

Expand Down
11 changes: 5 additions & 6 deletions repa/Data/Array/Repa/Eval/Reduction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ module Data.Array.Repa.Eval.Reduction
( foldS, foldP
, foldAllS, foldAllP)
where
import Data.Array.Repa.Eval.Elt
import Data.Array.Repa.Eval.Gang
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as M
import GHC.Base ( quotInt, divInt )
import GHC.Exts


-- | Sequential reduction of a multidimensional array along the innermost dimension.
foldS :: (Elt a, V.Unbox a)
foldS :: V.Unbox a
=> M.IOVector a -- ^ vector to write elements into
-> (Int# -> a) -- ^ function to get an element from the given index
-> (a -> a -> a) -- ^ binary associative combination function
Expand All @@ -38,7 +38,7 @@ foldS !vec get c !r !n
-- | Parallel reduction of a multidimensional array along the innermost dimension.
-- Each output value is computed by a single thread, with the output values
-- distributed evenly amongst the available threads.
foldP :: (Elt a, V.Unbox a)
foldP :: V.Unbox a
=> M.IOVector a -- ^ vector to write elements into
-> (Int -> a) -- ^ function to get an element from the given index
-> (a -> a -> a) -- ^ binary associative combination operator
Expand Down Expand Up @@ -78,8 +78,7 @@ foldP vec f c !r (I# n)


-- | Sequential reduction of all the elements in an array.
foldAllS :: (Elt a, V.Unbox a)
=> (Int# -> a) -- ^ function to get an element from the given index
foldAllS :: (Int# -> a) -- ^ function to get an element from the given index
-> (a -> a -> a) -- ^ binary associative combining function
-> a -- ^ starting value
-> Int# -- ^ number of elements
Expand All @@ -99,7 +98,7 @@ foldAllS f c !r !len
-- computes a fold1 on its chunk of the data, and the seed element is only
-- applied in the final reduction step.
--
foldAllP :: (Elt a, V.Unbox a)
foldAllP :: V.Unbox a
=> (Int -> a) -- ^ function to get an element from the given index
-> (a -> a -> a) -- ^ binary associative combining function
-> a -- ^ starting value
Expand Down
4 changes: 1 addition & 3 deletions repa/Data/Array/Repa/Operators/IndexSpace.hs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ extract start sz arr
-- | Backwards permutation of an array's elements.
backpermute, unsafeBackpermute
:: forall r sh1 sh2 e
. ( Shape sh1, Shape sh2
. ( Shape sh1
, Source r e)
=> sh2 -- ^ Extent of result array.
-> (sh2 -> sh1) -- ^ Function mapping each index in the result array
Expand Down Expand Up @@ -152,7 +152,6 @@ unsafeBackpermuteDft arrDft fnIndex arrSrc
extend, unsafeExtend
:: ( Slice sl
, Shape (SliceShape sl)
, Shape (FullShape sl)
, Source r e)
=> sl
-> Array r (SliceShape sl) e
Expand Down Expand Up @@ -187,7 +186,6 @@ unsafeExtend sl arr
slice, unsafeSlice
:: ( Slice sl
, Shape (FullShape sl)
, Shape (SliceShape sl)
, Source r e)
=> Array r (FullShape sl) e
-> sl
Expand Down
20 changes: 10 additions & 10 deletions repa/Data/Array/Repa/Operators/Reduction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import GHC.Exts
-- >>> foldS c 0 a
-- AUnboxed (Z :. 2) (fromList [2,4])
--
foldS :: (Shape sh, Source r a, Elt a, Unbox a)
foldS :: (Shape sh, Source r a, Unbox a)
=> (a -> a -> a)
-> a
-> Array r (sh :. Int) a
Expand Down Expand Up @@ -67,7 +67,7 @@ foldS f z arr
-- >>> foldP c 0 a
-- AUnboxed (Z :. 2) (fromList [2,4])
--
foldP :: (Shape sh, Source r a, Elt a, Unbox a, Monad m)
foldP :: (Shape sh, Source r a, Unbox a, Monad m)
=> (a -> a -> a)
-> a
-> Array r (sh :. Int) a
Expand Down Expand Up @@ -100,7 +100,7 @@ foldP f z arr
-- Elements are reduced in row-major order. Applications of the operator are
-- associated arbitrarily.
--
foldAllS :: (Shape sh, Source r a, Elt a, Unbox a)
foldAllS :: (Shape sh, Source r a)
=> (a -> a -> a)
-> a
-> Array r sh a
Expand Down Expand Up @@ -128,7 +128,7 @@ foldAllS f z arr
-- associated arbitrarily.
--
foldAllP
:: (Shape sh, Source r a, Elt a, Unbox a, Monad m)
:: (Shape sh, Source r a, Unbox a, Monad m)
=> (a -> a -> a)
-> a
-> Array r sh a
Expand All @@ -146,15 +146,15 @@ foldAllP f z arr

-- sum ------------------------------------------------------------------------
-- | Sequential sum the innermost dimension of an array.
sumS :: (Shape sh, Source r a, Num a, Elt a, Unbox a)
sumS :: (Shape sh, Source r a, Num a, Unbox a)
=> Array r (sh :. Int) a
-> Array U sh a
sumS = foldS (+) 0
{-# INLINE [3] sumS #-}


-- | Parallel sum the innermost dimension of an array.
sumP :: (Shape sh, Source r a, Num a, Elt a, Unbox a, Monad m)
sumP :: (Shape sh, Source r a, Num a, Unbox a, Monad m)
=> Array r (sh :. Int) a
-> m (Array U sh a)
sumP = foldP (+) 0
Expand All @@ -163,15 +163,15 @@ sumP = foldP (+) 0

-- sumAll ---------------------------------------------------------------------
-- | Sequential sum of all the elements of an array.
sumAllS :: (Shape sh, Source r a, Elt a, Unbox a, Num a)
sumAllS :: (Shape sh, Source r a, Num a)
=> Array r sh a
-> a
sumAllS = foldAllS (+) 0
{-# INLINE [3] sumAllS #-}


-- | Parallel sum all the elements of an array.
sumAllP :: (Shape sh, Source r a, Elt a, Unbox a, Num a, Monad m)
sumAllP :: (Shape sh, Source r a, Unbox a, Num a, Monad m)
=> Array r sh a
-> m a
sumAllP = foldAllP (+) 0
Expand All @@ -187,7 +187,7 @@ instance (Shape sh, Eq sh, Source r a, Eq a) => Eq (Array r sh a) where

-- | Check whether two arrays have the same shape and contain equal elements,
-- in parallel.
equalsP :: (Shape sh, Eq sh, Source r1 a, Source r2 a, Eq a, Monad m)
equalsP :: (Shape sh, Source r1 a, Source r2 a, Eq a, Monad m)
=> Array r1 sh a
-> Array r2 sh a
-> m Bool
Expand All @@ -198,7 +198,7 @@ equalsP arr1 arr2

-- | Check whether two arrays have the same shape and contain equal elements,
-- sequentially.
equalsS :: (Shape sh, Eq sh, Source r1 a, Source r2 a, Eq a)
equalsS :: (Shape sh, Source r1 a, Source r2 a, Eq a)
=> Array r1 sh a
-> Array r2 sh a
-> Bool
Expand Down
8 changes: 4 additions & 4 deletions repa/Data/Array/Repa/Operators/Traversal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Prelude hiding (traverse)
traverse, unsafeTraverse
:: forall r sh sh' a b
. ( Source r a
, Shape sh, Shape sh')
, Shape sh)
=> Array r sh a -- ^ Source array.
-> (sh -> sh') -- ^ Function to produce the extent of the result.
-> ((sh -> a) -> sh' -> b) -- ^ Function to produce elements of the result.
Expand All @@ -35,7 +35,7 @@ unsafeTraverse arr transExtent newElem
traverse2, unsafeTraverse2
:: forall r1 r2 sh sh' sh'' a b c
. ( Source r1 a, Source r2 b
, Shape sh, Shape sh', Shape sh'')
, Shape sh, Shape sh')
=> Array r1 sh a -- ^ First source array.
-> Array r2 sh' b -- ^ Second source array.
-> (sh -> sh' -> sh'') -- ^ Function to produce the extent of the result.
Expand All @@ -62,7 +62,7 @@ traverse3, unsafeTraverse3
sh1 sh2 sh3 sh4
a b c d
. ( Source r1 a, Source r2 b, Source r3 c
, Shape sh1, Shape sh2, Shape sh3, Shape sh4)
, Shape sh1, Shape sh2, Shape sh3)
=> Array r1 sh1 a
-> Array r2 sh2 b
-> Array r3 sh3 c
Expand All @@ -89,7 +89,7 @@ traverse4, unsafeTraverse4
sh1 sh2 sh3 sh4 sh5
a b c d e
. ( Source r1 a, Source r2 b, Source r3 c, Source r4 d
, Shape sh1, Shape sh2, Shape sh3, Shape sh4, Shape sh5)
, Shape sh1, Shape sh2, Shape sh3, Shape sh4)
=> Array r1 sh1 a
-> Array r2 sh2 b
-> Array r3 sh3 c
Expand Down
3 changes: 1 addition & 2 deletions repa/Data/Array/Repa/Repr/ByteString.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ deriving instance Read sh
-- Conversions ----------------------------------------------------------------
-- | O(1). Wrap a `ByteString` as an array.
fromByteString
:: Shape sh
=> sh -> ByteString -> Array B sh Word8
:: sh -> ByteString -> Array B sh Word8
fromByteString sh bs
= AByteString sh bs
{-# INLINE fromByteString #-}
Expand Down
14 changes: 4 additions & 10 deletions repa/Data/Array/Repa/Repr/Unboxed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ instance U.Unbox e => Target U e where
-- * This is an alias for `computeS` with a more specific type.
--
computeUnboxedS
:: ( Shape sh
, Load r1 sh e, U.Unbox e)
:: (Load r1 sh e, U.Unbox e)
=> Array r1 sh e -> Array U sh e
computeUnboxedS = computeS
{-# INLINE computeUnboxedS #-}
Expand All @@ -102,8 +101,7 @@ computeUnboxedS = computeS
-- * This is an alias for `computeP` with a more specific type.
--
computeUnboxedP
:: ( Shape sh
, Load r1 sh e, Monad m, U.Unbox e)
:: (Load r1 sh e, Monad m, U.Unbox e)
=> Array r1 sh e -> m (Array U sh e)
computeUnboxedP = computeP
{-# INLINE computeUnboxedP #-}
Expand All @@ -121,18 +119,14 @@ fromListUnboxed = R.fromList


-- | O(1). Wrap an unboxed vector as an array.
fromUnboxed
:: (Shape sh, U.Unbox e)
=> sh -> U.Vector e -> Array U sh e
fromUnboxed :: sh -> U.Vector e -> Array U sh e
fromUnboxed sh vec
= AUnboxed sh vec
{-# INLINE fromUnboxed #-}


-- | O(1). Unpack an unboxed vector from an array.
toUnboxed
:: U.Unbox e
=> Array U sh e -> U.Vector e
toUnboxed :: Array U sh e -> U.Vector e
toUnboxed (AUnboxed _ vec)
= vec
{-# INLINE toUnboxed #-}
Expand Down
2 changes: 1 addition & 1 deletion repa/Data/Array/Repa/Repr/Undefined.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ deriving instance Read sh
=> Read (Array X sh e)


instance (Shape sh, Num e) => Load X sh e where
instance Shape sh => Load X sh e where
loadS _ _ = return ()
loadP _ _ = return ()

Expand Down
10 changes: 4 additions & 6 deletions repa/Data/Array/Repa/Repr/Vector.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ instance Target V e where
-- * This is an alias for `compute` with a more specific type.
--
computeVectorS
:: (Shape sh, Load r1 sh e)
:: Load r1 sh e
=> Array r1 sh e -> Array V sh e
computeVectorS = computeS
{-# INLINE computeVectorS #-}


-- | Parallel computation of array elements.
computeVectorP
:: (Shape sh, Load r1 sh e, Monad m)
:: (Load r1 sh e, Monad m)
=> Array r1 sh e -> m (Array V sh e)
computeVectorP = computeP
{-# INLINE computeVectorP #-}
Expand All @@ -107,16 +107,14 @@ fromListVector = fromList


-- | O(1). Wrap a boxed vector as an array.
fromVector
:: Shape sh
=> sh -> V.Vector e -> Array V sh e
fromVector :: sh -> V.Vector e -> Array V sh e
fromVector sh vec
= AVector sh vec
{-# INLINE fromVector #-}


-- | O(1). Unpack a boxed vector from an array.
toVector :: Array V sh e -> V.Vector e
toVector :: Array V sh e -> V.Vector e
toVector (AVector _ vec)
= vec
{-# INLINE toVector #-}
Expand Down
4 changes: 2 additions & 2 deletions repa/Data/Array/Repa/Stencil/Template.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ parseStencil2 str
in makeStencil2' sizeX sizeY
$ filter (\(_, _, v) -> v /= 0)
$ [ (fromIntegral y, fromIntegral x, fromIntegral v)
| y <- [minX, minX + 1 .. maxX]
, x <- [minY, minY + 1 .. maxY]
| y <- [minX, minX + (1 :: Integer) .. maxX]
, x <- [minY, minY + (1 :: Integer) .. maxY]
| v <- coeffs ]


Expand Down
2 changes: 1 addition & 1 deletion repa/repa.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: repa
Version: 3.4.1.1
Version: 3.4.1.2
License: BSD3
License-file: LICENSE
Author: The DPH Team
Expand Down

0 comments on commit 71ca664

Please sign in to comment.