aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2014-10-08 18:03:01 +1100
committerJustin Bedo <cu@cua0.org>2014-10-08 22:02:56 +1100
commitf4f5c99fcce607e72847cb11fd3ec90b0c089a63 (patch)
tree1eedb231bfbc1e1abb53e9bfd27e695b2fc4d8c6
parent35b43189d5a262860ad84da43928eeb7b1894420 (diff)
Fix up FFI exports; fix cabal file; tidy source
-rw-r--r--LinProg.cabal6
-rw-r--r--Math/LinProg/Compile.hs3
-rw-r--r--Math/LinProg/LP.hs2
-rw-r--r--Math/LinProg/LPSolve/FFI.hs22
-rw-r--r--Math/LinProg/Types.hs1
-rw-r--r--default.nix1
6 files changed, 21 insertions, 14 deletions
diff --git a/LinProg.cabal b/LinProg.cabal
index 5ee19ba..b0ddf5b 100644
--- a/LinProg.cabal
+++ b/LinProg.cabal
@@ -17,8 +17,10 @@ cabal-version: >=1.10
library
exposed-modules: Math.LinProg.Types, Math.LinProg.LP, Math.LinProg.LPSolve
- -- other-modules:
- other-extensions: DeriveFunctor, FlexibleInstances, FlexibleContexts, UndecidableInstances, TemplateHaskell, ScopedTypeVariables
+ other-modules: Math.LinProg.Compile, Math.LinProg.LPSolve.FFI, Math.LinProg.Compile
+ extra-libraries: lpsolve55
+ extensions: DeriveFunctor, FlexibleInstances, FlexibleContexts, UndecidableInstances, TemplateHaskell, ScopedTypeVariables, ForeignFunctionInterface, ViewPatterns
build-depends: base >=4.7 && <4.8, recursion-schemes >=4.1 && <4.2, free >=4.9 && <4.10, containers >=0.5 && <0.6, lens >=4.4 && <4.5, mtl >=2.1 && <2.2
-- hs-source-dirs:
default-language: Haskell2010
+ ghc-options: -Wall -fno-warn-missing-signatures -fno-warn-name-shadowing
diff --git a/Math/LinProg/Compile.hs b/Math/LinProg/Compile.hs
index 07398e7..c14d45b 100644
--- a/Math/LinProg/Compile.hs
+++ b/Math/LinProg/Compile.hs
@@ -9,12 +9,9 @@ module Math.LinProg.Compile (
,leqs
) where
-import Data.List
import Math.LinProg.Types
import Control.Lens
-import Control.Monad.State
import Control.Monad.Free
-import Data.Maybe
type Equation t v = (LinExpr t v, t) -- LHS and RHS
diff --git a/Math/LinProg/LP.hs b/Math/LinProg/LP.hs
index 4ad8b79..50bcb1f 100644
--- a/Math/LinProg/LP.hs
+++ b/Math/LinProg/LP.hs
@@ -8,8 +8,6 @@ import Data.List
import Math.LinProg.Types
import Math.LinProg.Compile
import Control.Lens
-import Control.Monad.State
-import Control.Monad.Free
import Data.Maybe
instance (Show t, Num t, Ord t) => Show (CompilerS t String) where
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)
diff --git a/Math/LinProg/Types.hs b/Math/LinProg/Types.hs
index 8b95ef0..69da6bf 100644
--- a/Math/LinProg/Types.hs
+++ b/Math/LinProg/Types.hs
@@ -20,7 +20,6 @@ module Math.LinProg.Types (
import Data.Functor.Foldable
import Control.Monad.Free
-import qualified Data.Map as M
data LinExpr' t v a =
Lit t
diff --git a/default.nix b/default.nix
index 83c16f8..a1c9d56 100644
--- a/default.nix
+++ b/default.nix
@@ -13,6 +13,7 @@ in cabal.mkDerivation (self: {
pname = "LinProg";
version = "0.0.0.1";
src = ./.;
+ isLibrary = true;
buildDepends = [
recursionSchemes
lens