diff options
author | Justin Bedo <cu@cua0.org> | 2014-10-08 18:03:01 +1100 |
---|---|---|
committer | Justin Bedo <cu@cua0.org> | 2014-10-08 22:02:56 +1100 |
commit | f4f5c99fcce607e72847cb11fd3ec90b0c089a63 (patch) | |
tree | 1eedb231bfbc1e1abb53e9bfd27e695b2fc4d8c6 /Math/LinProg/LPSolve | |
parent | 35b43189d5a262860ad84da43928eeb7b1894420 (diff) |
Fix up FFI exports; fix cabal file; tidy source
Diffstat (limited to 'Math/LinProg/LPSolve')
-rw-r--r-- | Math/LinProg/LPSolve/FFI.hs | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/Math/LinProg/LPSolve/FFI.hs b/Math/LinProg/LPSolve/FFI.hs index eb818df..45b0a30 100644 --- a/Math/LinProg/LPSolve/FFI.hs +++ b/Math/LinProg/LPSolve/FFI.hs @@ -1,9 +1,19 @@ {-# LANGUAGE ForeignFunctionInterface #-} -module Math.LinProg.LPSolve.FFI where +module Math.LinProg.LPSolve.FFI ( + ResultCode(..) + ,ConstraintType(..) + ,LPRec + ,setConstrType + ,makeLP + ,freeLP + ,setMat + ,setRHS + ,solve + ,getSol +) where import Foreign import Foreign.C -import Foreign.Marshal.Array import Control.Applicative ((<$>)) import qualified Data.Map as M @@ -46,11 +56,11 @@ setConstrType lp i t = fromIntegral <$> c_set_constr_type lp (fromIntegral i) (f makeLP :: Int -> Int -> IO (Maybe LPRec) makeLP n m = do - m <- c_make_lp (fromIntegral n) (fromIntegral m) - return $ if m == nullPtr then + m' <- c_make_lp (fromIntegral n) (fromIntegral m) + return $ if m' == nullPtr then Nothing else - Just m + Just m' freeLP :: LPRec -> IO () freeLP m = with m $ \m' -> c_free_lp m' @@ -66,7 +76,7 @@ solve lp = (lut M.!) . fromIntegral <$> c_solve lp where lut = M.fromList [ (-2, NoMemory) - ,(0, Optimal) + ,(0 :: Int, Optimal) ,(1, SubOptimal) ,(2, Infeasible) ,(3, Unbounded) |