Skip to content

Commit eb6d2d9

Browse files
committed
It seems to be working!
1 parent e53d103 commit eb6d2d9

File tree

12 files changed

+43
-40
lines changed

12 files changed

+43
-40
lines changed

Foreign/Matlab.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{-# OPTIONS_GHC -fno-implicit-prelude #-}
1+
{-# LANGUAGE NoImplicitPrelude #-}
22

33
{-|
44
Bundles Matlab data structure and general-purpose routines.

Foreign/Matlab/Array.hsc

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,16 @@ module Foreign.Matlab.Array (
1919
mIndexOffset,
2020

2121
-- * Array element access
22-
MXArrayComponent,
22+
MXArrayComponent (mxArrayGetOffset, mxArraySetOffset
23+
, mxArrayGetOffsetList, mxArraySetOffsetList
24+
, mxScalarGet, isMXScalar
25+
, createMXArray, createMXScalar
26+
, createColVector, createRowVector),
2327
castMXArray,
24-
-- |raw array element access
25-
mxArrayGetOffset, mxArraySetOffset,
26-
-- |raw array list access
27-
mxArrayGetOffsetList, mxArraySetOffsetList,
28-
-- |array element access
28+
-- | array element access
2929
mxArrayGet, mxArraySet,
30-
-- |array list access
30+
-- | array list access
3131
mxArrayGetList, mxArraySetList,
32-
mxScalarGet, isMXScalar,
33-
createMXArray, createMXScalar,
34-
createColVector, createRowVector,
3532
mxArrayGetAll, mxArraySetAll,
3633

3734
-- * Struct access

Foreign/Matlab/Array/Able.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
In general, scalars convert to the obvious, and lists to row vectors.
55
-}
66
module Foreign.Matlab.Array.Able (
7-
Matlabable,
8-
toMatlab, fromMatlab,
7+
Matlabable (toMatlab, fromMatlab),
98
withMatlabArray, fromMatlabArray
109
) where
1110

Foreign/Matlab/Array/Auto.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ module Foreign.Matlab.Array.Auto (
1313
import Foreign
1414
import Foreign.Matlab.Util
1515
import Foreign.Matlab.Internal
16-
import Foreign.Matlab.Types
1716

1817
-- |A 'MXArray' that is automatically freed with 'Foreign.Matlab.Array.freeMXArray'
1918
newtype MXAuto a = MXAuto (ForeignPtr MXArrayType)

Foreign/Matlab/Array/IMX.hs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
-}
77
module Foreign.Matlab.Array.IMX (
88
IMXData(..),
9-
IMXArrayElem,
9+
IMXArrayElem (imxConstr, imxArray),
1010

1111
-- * Interface with "Foreign.Matlab.Array"
1212
imxData, iMXData,
@@ -16,7 +16,6 @@ module Foreign.Matlab.Array.IMX (
1616

1717
-- * Construction and access
1818
imxSize,
19-
imxConstr, imxArray,
2019
listIMX, scalarIMX,
2120
imxList, imxScalar,
2221
listIMXStruct,
@@ -27,7 +26,6 @@ import Control.Monad
2726
import Data.Array.IArray
2827
import Data.Complex
2928
import Data.List
30-
import Text.Show
3129
import Foreign.Matlab.Util
3230
import Foreign.Matlab.Internal
3331
import Foreign.Matlab.Types
@@ -191,7 +189,7 @@ iMXData = imxd where
191189
imxd (IMXStruct f a) = do
192190
let ((r0,_),(r1,_)) = bounds a
193191
m <- createStruct (mRangeSize (r0,r1)) f
194-
zipWithM (\i -> mStructSetFields m (mOffset i) <=< mapM iMXData) [0..] (segment (length f) (elems a))
192+
zipWithM_ (\i -> mStructSetFields m (mOffset i) <=< mapM iMXData) [0..] (segment (length f) (elems a))
195193
return $ anyMXArray m
196194
imxd (IMXLogical a) = imxa a return
197195
imxd (IMXChar a) = imxa a return

Foreign/Matlab/Config.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
-- FIXME: This file needs to be regenerated from Config.hs.in by configure, but is required to exist for sdist.
1+
module Foreign.Matlab.Config (matlabPath, matlabBin, matlabArch, dllExtension) where
2+
3+
import Distribution.Simple.BuildPaths (dllExtension)
4+
5+
matlabPath :: FilePath
6+
matlabBin :: FilePath
7+
matlabArch :: String
8+
9+
matlabPath = "/usr/local/MATLAB/R2013a"
10+
matlabBin = "/usr/local/MATLAB/R2013a/bin/matlab"
11+
matlabArch = "glnxa64"

Foreign/Matlab/Engine.hsc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import Foreign.C.Types
2222
import Data.List
2323
import Foreign.Matlab.Util
2424
import Foreign.Matlab.Internal
25-
import Foreign.Matlab.Types
2625
import Foreign.Matlab.Config
2726

2827
#include <engine.h>

Foreign/Matlab/Runtime.hsc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ module Foreign.Matlab.Runtime (
1616
mlGenericFeval
1717
) where
1818

19-
import Control.Monad
20-
import Foreign
19+
import Foreign hiding (unsafePerformIO)
2120
import Foreign.C.String
2221
import Foreign.C.Types
2322
import System.Posix.DynamicLinker
@@ -28,7 +27,8 @@ import System.FilePath
2827
import Foreign.Matlab.Config
2928
import Foreign.Matlab.Util
3029
import Foreign.Matlab.Internal
31-
import Foreign.Matlab.Types
30+
31+
import System.IO.Unsafe (unsafePerformIO)
3232

3333
#include "hsc_sym.h"
3434
#include "libhsmatlab.h"
@@ -65,16 +65,16 @@ initialize = initializeApp mclInitializeApplication
6565
terminate = terminateApp mclTerminateApplication
6666
-}
6767

68-
foreign import ccall "dynamic" mkInitApp :: FunPtr a -> InitApp
69-
foreign import ccall "dynamic" mkTermApp :: FunPtr a -> TermApp
68+
foreign import ccall "dynamic" mkInitApp :: FunPtr InitApp -> InitApp
69+
foreign import ccall "dynamic" mkTermApp :: FunPtr TermApp -> TermApp
7070

7171
type InitFun = IO CBool
7272
type FiniFun = IO ()
7373
type MLXFun = CInt -> Ptr MXArrayPtr -> CInt -> Ptr MXArrayPtr -> IO CBool
7474

75-
foreign import ccall "dynamic" mkInitFun :: FunPtr a -> InitFun
76-
foreign import ccall "dynamic" mkFiniFun :: FunPtr a -> FiniFun
77-
foreign import ccall "dynamic" mkMLXFun :: FunPtr a -> MLXFun
75+
foreign import ccall "dynamic" mkInitFun :: FunPtr InitFun -> InitFun
76+
foreign import ccall "dynamic" mkFiniFun :: FunPtr FiniFun -> FiniFun
77+
foreign import ccall "dynamic" mkMLXFun :: FunPtr MLXFun -> MLXFun
7878

7979
-- |A Matlab library handle
8080
data MLibrary = MLibrary { mlName :: String, mlDL :: DL }
@@ -129,7 +129,7 @@ mLibraryCall ml f arg no = do
129129
fun <- mLibraryFun ml f
130130
fun arg no
131131

132-
foreign import ccall "dynamic" mkFeval :: FunPtr a -> CString -> MLXFun
132+
foreign import ccall "dynamic" mkFeval :: FunPtr (CString -> MLXFun) -> CString -> MLXFun
133133

134134
-- |Internal use only. See "Foreign.Matlab.Runtime.Generic"
135135
mlGenericFeval :: MLibrary -> IO (CString -> MFun)

Foreign/Matlab/Runtime/Generic.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module Foreign.Matlab.Runtime.Generic (
1414
mlGenericCapture
1515
) where
1616

17-
import Control.Monad
1817
import Foreign.C.String
1918
--import System.FilePath
2019
import Foreign.Matlab.Util
@@ -61,7 +60,7 @@ mlGenericSetVar :: MLGeneric -> String -> MXArray a -> IO ()
6160
mlGenericSetVar mlg v x = do
6261
b <- createRowVector "base"
6362
v <- createRowVector v
64-
mlGenericFun mlg "assignin" [anyMXArray b,anyMXArray v,anyMXArray x] 0
63+
_ <- mlGenericFun mlg "assignin" [anyMXArray b,anyMXArray v,anyMXArray x] 0
6564
freeMXArray v
6665
freeMXArray b
6766

Setup.hs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import System.FilePath
1212
defhooks = autoconfUserHooks
1313
programs = [
1414
simpleProgram "matlab",
15-
(simpleProgram "mcr") { programFindLocation = \_ -> return Nothing }
15+
(simpleProgram "mcr") { programFindLocation =
16+
\_ -> return (return Nothing) }
1617
]
1718
runtime desc = maybe False (elem ["Foreign","Matlab","Runtime"] . map components . exposedModules) $ library desc
1819
postconf args flags desc build = do
@@ -22,7 +23,8 @@ postconf args flags desc build = do
2223
where
2324
verb = fromFlag $ configVerbosity flags
2425
confargs = ("--" ++ (if runtime desc then "enable" else "disable") ++ "-runtime") : map pconfarg pconf
25-
pconfarg p = "--with-" ++ programId p ++ "=" ++ programPath p ++ " " ++ unwords (programArgs p)
26+
pconfarg p = "--with-" ++ programId p ++ "=" ++ programPath p
27+
-- ++ " " ++ unwords (programArgs p)
2628
pconf = mapMaybe (\p -> lookupProgram p (withPrograms build)) programs
2729
build desc binfo hooks flags = do
2830
when (runtime desc) $ rawSystemExit (fromFlag $ buildVerbosity flags) "make" ["-Csrc"]
@@ -37,13 +39,14 @@ install desc binfo hooks flags = do
3739
copyFileVerbose (fromFlag $ installVerbosity flags)
3840
("src" </> f)
3941
(libdir (absoluteInstallDirs desc binfo NoCopyDest) </> f))
40-
["libhsmatlab.so","libhsmatlab.ctf"]
42+
["libhsmatlab.so"{-,"libhsmatlab.ctf"-}]
4143
reg desc binfo hooks flags = do
4244
pwd <- getCurrentDirectory
4345
let
4446
desc' = desc{ library = fmap lm (library desc) }
45-
lm l = l{ libBuildInfo = (libBuildInfo l)
46-
{ ldOptions = ("-Wl,-rpath," ++ lib) : ldOptions (libBuildInfo l) } }
47+
lm l = l { libBuildInfo = (libBuildInfo l)
48+
{ ldOptions = ("-Wl,-rpath," ++ lib) : ldOptions (libBuildInfo l),
49+
extraLibDirs = (pwd </> "src") : extraLibDirs (libBuildInfo l) } }
4750
lib
4851
| fromFlag $ regInPlace flags = pwd </> "src"
4952
| otherwise = libdir (absoluteInstallDirs desc binfo NoCopyDest)

0 commit comments

Comments
 (0)