-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathUtil.hs
More file actions
33 lines (25 loc) · 736 Bytes
/
Util.hs
File metadata and controls
33 lines (25 loc) · 736 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module ArrayFire.Util where
import Control.Monad
import Control.Exception
import Foreign.Marshal hiding (void)
import Foreign.Storable
import Foreign.ForeignPtr
import ArrayFire.Internal.Util
import ArrayFire.Internal.Defines
import ArrayFire.Types
type Version = (Int,Int,Int)
getVersion :: IO Version
getVersion = do
alloca $ \x ->
alloca $ \y ->
alloca $ \z -> do
r <- af_get_version x y z
when (r /= afSuccess) (error "oops")
x <- (,,) <$> peek x <*> peek y <*> peek z
pure x
printAFArray :: AFArray -> IO ()
printAFArray a = () <$ af_print_array a
printArray :: Array a -> IO ()
printArray (Array fptr) =
void (withForeignPtr fptr af_print_array)
getRevision = af_get_revision