From 15701d49861fb0596b63b9d855e4f7f63c13a2ba Mon Sep 17 00:00:00 2001 From: Tom Westerhout <14264576+twesterhout@users.noreply.github.com> Date: Fri, 20 May 2022 00:54:58 +0200 Subject: [PATCH] Fix compilation on GHC 9.0.2 --- arrayfire.cabal | 3 ++- src/ArrayFire/Arith.hs | 2 +- src/ArrayFire/Array.hs | 4 ++-- src/ArrayFire/Data.hs | 12 ++++++------ src/ArrayFire/Image.hs | 2 +- src/ArrayFire/Random.hs | 4 ++-- src/ArrayFire/Vision.hs | 2 +- test/ArrayFire/UtilSpec.hs | 28 ++++++++++++++-------------- 8 files changed, 29 insertions(+), 28 deletions(-) diff --git a/arrayfire.cabal b/arrayfire.cabal index e2dfe1f..9a04609 100644 --- a/arrayfire.cabal +++ b/arrayfire.cabal @@ -145,10 +145,11 @@ test-suite test base < 5, directory, hspec, - hspec-discover, QuickCheck, quickcheck-classes, vector + build-tool-depends: + hspec-discover:hspec-discover default-language: Haskell2010 other-modules: diff --git a/src/ArrayFire/Arith.hs b/src/ArrayFire/Arith.hs index 7a1b819..f74548a 100644 --- a/src/ArrayFire/Arith.hs +++ b/src/ArrayFire/Arith.hs @@ -719,7 +719,7 @@ cast cast afArr = coerce $ afArr `op1` (\x y -> af_cast x y dtyp) where - dtyp = afType (Proxy @ b) + dtyp = afType (Proxy @b) -- | Find the minimum of two 'Array's -- diff --git a/src/ArrayFire/Array.hs b/src/ArrayFire/Array.hs index 3a6fb53..7c36359 100644 --- a/src/ArrayFire/Array.hs +++ b/src/ArrayFire/Array.hs @@ -196,7 +196,7 @@ mkArray dims xs = Array <$> newForeignPtr af_release_array_finalizer arr where size = Prelude.product dims - dType = afType (Proxy @ array) + dType = afType (Proxy @array) -- af_err af_create_handle(af_array *arr, const unsigned ndims, const dim_t * const dims, const af_dtype type); @@ -482,7 +482,7 @@ toVector :: forall a . AFType a => Array a -> Vector a toVector arr@(Array fptr) = do unsafePerformIO . mask_ . withForeignPtr fptr $ \arrPtr -> do let len = getElements arr - size = len * getSizeOf (Proxy @ a) + size = len * getSizeOf (Proxy @a) ptr <- mallocBytes (len * size) throwAFError =<< af_get_data_ptr (castPtr ptr) arrPtr newFptr <- newForeignPtr finalizerFree ptr diff --git a/src/ArrayFire/Data.hs b/src/ArrayFire/Data.hs index 78061cf..ab3b8e6 100644 --- a/src/ArrayFire/Data.hs +++ b/src/ArrayFire/Data.hs @@ -91,7 +91,7 @@ constant dims val = cast $ constant' dims (realToFrac (unsafeCoerce val :: Float)) | otherwise -> error "constant: Invalid array fire type" where - dtyp = afType (Proxy @ a) + dtyp = afType (Proxy @a) constant' :: [Int] @@ -112,7 +112,7 @@ constant dims val = ptr where n = fromIntegral (length dims') - typ = afType (Proxy @ Double) + typ = afType (Proxy @Double) -- | Creates an 'Array (Complex Double)' from a scalar val'ue -- @@ -139,7 +139,7 @@ constant dims val = ptr where n = fromIntegral (length dims') - typ = afType (Proxy @ (Complex arr)) + typ = afType (Proxy @(Complex arr)) -- | Creates an 'Array Int64' from a scalar val'ue -- @@ -221,7 +221,7 @@ range dims (fromIntegral -> k) = unsafePerformIO $ do ptr where n = fromIntegral (length dims) - typ = afType (Proxy @ a) + typ = afType (Proxy @a) -- | Create an sequence [0, dims.elements() - 1] and modify to specified dimensions dims and then tile it according to tile_dims. -- @@ -266,7 +266,7 @@ iota dims tdims = unsafePerformIO $ do af_release_array_finalizer ptr where - typ = afType (Proxy @ a) + typ = afType (Proxy @a) -- | Creates the identity `Array` from given dimensions -- @@ -293,7 +293,7 @@ identity dims = unsafePerformIO . mask_ $ do ptr where n = fromIntegral (length dims) - typ = afType (Proxy @ a) + typ = afType (Proxy @a) -- | Create a diagonal matrix from input array when extract is set to false -- diff --git a/src/ArrayFire/Image.hs b/src/ArrayFire/Image.hs index 3df7619..e8b55fb 100644 --- a/src/ArrayFire/Image.hs +++ b/src/ArrayFire/Image.hs @@ -423,7 +423,7 @@ regions regions in' (fromConnectivity -> conn) = in' `op1` (\ptr k -> af_regions ptr k conn dtype) where - dtype = afType (Proxy @ a) + dtype = afType (Proxy @a) -- | Sobel Operators. -- diff --git a/src/ArrayFire/Random.hs b/src/ArrayFire/Random.hs index 9374a9a..a89ebcd 100644 --- a/src/ArrayFire/Random.hs +++ b/src/ArrayFire/Random.hs @@ -240,7 +240,7 @@ randEng dims f (RandomEngine fptr) = mask_ $ ptr where n = fromIntegral (length dims) - typ = afType (Proxy @ a) + typ = afType (Proxy @a) rand :: forall a . AFType a @@ -260,7 +260,7 @@ rand dims f = mask_ $ do ptr where n = fromIntegral (length dims) - typ = afType (Proxy @ a) + typ = afType (Proxy @a) -- | Generate random 'Array' -- diff --git a/src/ArrayFire/Vision.hs b/src/ArrayFire/Vision.hs index 4f3d8c1..2587477 100644 --- a/src/ArrayFire/Vision.hs +++ b/src/ArrayFire/Vision.hs @@ -360,4 +360,4 @@ homography (,) <$> do fromIntegral <$> peek outPtrI <*> do Array <$> newForeignPtr af_release_array_finalizer arrayPtr where - dtype = afType (Proxy @ a) + dtype = afType (Proxy @a) diff --git a/test/ArrayFire/UtilSpec.hs b/test/ArrayFire/UtilSpec.hs index 951aaac..7ac7dc4 100644 --- a/test/ArrayFire/UtilSpec.hs +++ b/test/ArrayFire/UtilSpec.hs @@ -15,20 +15,20 @@ spec :: Spec spec = describe "Util spec" $ do it "Should get size of" $ do - A.getSizeOf (Proxy @ Int) `shouldBe` 8 - A.getSizeOf (Proxy @ Int64) `shouldBe` 8 - A.getSizeOf (Proxy @ Int32) `shouldBe` 4 - A.getSizeOf (Proxy @ Int16) `shouldBe` 2 - A.getSizeOf (Proxy @ Word) `shouldBe` 8 - A.getSizeOf (Proxy @ Word64) `shouldBe` 8 - A.getSizeOf (Proxy @ Word32) `shouldBe` 4 - A.getSizeOf (Proxy @ Word16) `shouldBe` 2 - A.getSizeOf (Proxy @ Word8) `shouldBe` 1 - A.getSizeOf (Proxy @ CBool) `shouldBe` 1 - A.getSizeOf (Proxy @ Double) `shouldBe` 8 - A.getSizeOf (Proxy @ Float) `shouldBe` 4 - A.getSizeOf (Proxy @ (Complex Float)) `shouldBe` 8 - A.getSizeOf (Proxy @ (Complex Double)) `shouldBe` 16 + A.getSizeOf (Proxy @Int) `shouldBe` 8 + A.getSizeOf (Proxy @Int64) `shouldBe` 8 + A.getSizeOf (Proxy @Int32) `shouldBe` 4 + A.getSizeOf (Proxy @Int16) `shouldBe` 2 + A.getSizeOf (Proxy @Word) `shouldBe` 8 + A.getSizeOf (Proxy @Word64) `shouldBe` 8 + A.getSizeOf (Proxy @Word32) `shouldBe` 4 + A.getSizeOf (Proxy @Word16) `shouldBe` 2 + A.getSizeOf (Proxy @Word8) `shouldBe` 1 + A.getSizeOf (Proxy @CBool) `shouldBe` 1 + A.getSizeOf (Proxy @Double) `shouldBe` 8 + A.getSizeOf (Proxy @Float) `shouldBe` 4 + A.getSizeOf (Proxy @(Complex Float)) `shouldBe` 8 + A.getSizeOf (Proxy @(Complex Double)) `shouldBe` 16 it "Should get version" $ do x <- A.getVersion x `shouldBe` (3,6,4)