Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion arrayfire.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/ArrayFire/Arith.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
--
Expand Down
4 changes: 2 additions & 2 deletions src/ArrayFire/Array.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/ArrayFire/Data.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
--
Expand All @@ -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
--
Expand Down Expand Up @@ -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.
--
Expand Down Expand Up @@ -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
--
Expand All @@ -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
--
Expand Down
2 changes: 1 addition & 1 deletion src/ArrayFire/Image.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
--
Expand Down
4 changes: 2 additions & 2 deletions src/ArrayFire/Random.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
--
Expand Down
2 changes: 1 addition & 1 deletion src/ArrayFire/Vision.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
28 changes: 14 additions & 14 deletions test/ArrayFire/UtilSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down