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
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ jobs:
- uses: cachix/install-nix-action@v18
with:
nix_path: nixpkgs=channel:nixos-unstable
- run: s/pipeline
- run: |
nix develop --command cabal test all --test-show-details=streaming
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
.dir-locals-2.el

# Haskell
dist-newstyle/
dist-newstyle/

# direnv
.direnv
22 changes: 0 additions & 22 deletions default.nix

This file was deleted.

36 changes: 18 additions & 18 deletions examples/examples.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ executable sudoku
default-language: Haskell2010
ghc-options: -threaded -pgmL markdown-unlit
build-depends: base <5
, containers ^>=0.6
, markdown-unlit ^>=0.5
, math-programming ^>=0.5
, math-programming-glpk ^>=0.5
, mtl ^>=2.2
, text ^>=1.2
, containers >=0.6
, markdown-unlit >=0.5
, math-programming >=0.5
, math-programming-glpk >=0.5
, mtl >=2.2
, text >=1.2

executable 3sat
main-is: Example3SAT.lhs
hs-source-dirs: app
default-language: Haskell2010
ghc-options: -threaded -pgmL markdown-unlit
build-depends: base <5
, containers ^>=0.6
, markdown-unlit ^>=0.5
, math-programming ^>=0.5
, math-programming-glpk ^>=0.5
, mtl ^>=2.2
, text ^>=1.2
, containers >=0.6
, markdown-unlit >=0.5
, math-programming >=0.5
, math-programming-glpk >=0.5
, mtl >=2.2
, text >=1.2


executable tutorial
Expand All @@ -50,9 +50,9 @@ executable tutorial
default-language: Haskell2010
ghc-options: -threaded -pgmL markdown-unlit
build-depends: base <5
, containers ^>=0.6
, markdown-unlit ^>=0.5
, math-programming ^>=0.5
, math-programming-glpk ^>=0.5
, mtl ^>=2.2
, text ^>=1.2
, containers >=0.6
, markdown-unlit >=0.5
, math-programming >=0.5
, math-programming-glpk >=0.5
, mtl >=2.2
, text >=1.2
1 change: 0 additions & 1 deletion examples/shell.nix

This file was deleted.

43 changes: 43 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
description = "A collection of libraries for mathematical programming";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
systems.url = "github:nix-systems/default";
};

outputs = { self, nixpkgs, systems }:
let
forAllSystems = nixpkgs.lib.genAttrs (import systems);
mkPkgs = system: import nixpkgs { inherit system; overlays = [ self.overlays.default ]; };
in
{
packages = forAllSystems (system:
let
pkgs = mkPkgs system;
in
{ });

devShells = forAllSystems (system:
let
pkgs = mkPkgs system;
in
{
default = pkgs.haskellPackages.shellFor {
packages = hpkgs: with hpkgs; [
examples
glpk-headers
math-programming
math-programming-glpk
math-programming-tests
];
buildInputs = with pkgs; [
haskellPackages.haskell-language-server
ormolu
cabal-install
];
withHoogle = true;
};
});

overlays = {
default = final: prev: {
haskellPackages = prev.haskellPackages.override {
overrides = hfinal: hprev: {
examples = hfinal.callCabal2nix "examples" ./examples { };
glpk-headers = hfinal.callCabal2nix "glpk-headers" ./glpk-headers { };
math-programming = hfinal.callCabal2nix "math-programming" ./math-programming { };
math-programming-glpk = hfinal.callCabal2nix "math-programming-glpk" ./math-programming-glpk { };
math-programming-tests = hfinal.callCabal2nix "math-programming-tests" ./math-programming-tests { };
};
};
};
};
};
}
1 change: 0 additions & 1 deletion glpk-headers/shell.nix

This file was deleted.

18 changes: 9 additions & 9 deletions math-programming-glpk/math-programming-glpk.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ library
other-modules: Math.Programming.Glpk.Internal
ghc-options: -Wall
build-depends: base <5
, glpk-headers ^>=0.5
, math-programming ^>=0.5
, mtl ^>=2.2
, text ^>=1.2
, transformers ^>=0.5
, unliftio ^>=0.2
, glpk-headers >=0.5
, math-programming >=0.5
, mtl >=2.2
, text >=1.2
, transformers >=0.5
, unliftio >=0.2

test-suite math-programming-glpk-test-suite
default-language: Haskell2010
Expand All @@ -40,7 +40,7 @@ test-suite math-programming-glpk-test-suite
ghc-options: -threaded -with-rtsopts=-N -Wall
build-depends: math-programming-glpk
, base <5
, math-programming ^>=0.5
, math-programming-tests ^>=0.5
, unliftio ^>=0.2
, math-programming >=0.5
, math-programming-tests >=0.5
, unliftio >=0.2
, hspec >=2.8 && < 3
1 change: 0 additions & 1 deletion math-programming-glpk/shell.nix

This file was deleted.

18 changes: 9 additions & 9 deletions math-programming-tests/math-programming-tests.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ library
other-modules:
ghc-options: -Wall
build-depends: base <5
, containers ^>=0.6
, math-programming ^>=0.5
, microlens ^>=0.4
, microlens-th ^>=0.4
, microlens-mtl ^>=0.2
, containers >=0.6
, math-programming >=0.5
, microlens >=0.4
, microlens-th >=0.4
, microlens-mtl >=0.2
, hspec >=2.8 && <3
, QuickCheck ^>=2.14
, random ^>=1.2
, mtl ^>=2.2
, text ^>=1.2
, QuickCheck >=2.14
, random >=1.2
, mtl >=2.2
, text >=1.2
1 change: 0 additions & 1 deletion math-programming-tests/shell.nix

This file was deleted.

18 changes: 10 additions & 8 deletions math-programming-tests/src/Math/Programming/Tests/Fuzz.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
-- | Fuzz testing for math programming backends.
module Math.Programming.Tests.Fuzz where

import Control.Monad
import Control.Monad.IO.Class
import Control.Monad.State
import Control.Monad.Writer
Expand Down Expand Up @@ -107,7 +108,7 @@ type LPFuzz v c o m =
MonadIO m
)

evalPending :: LPFuzz v c o m => m ()
evalPending :: (LPFuzz v c o m) => m ()
evalPending = do
todo <- use pending
case todo of
Expand All @@ -117,10 +118,10 @@ evalPending = do
evalAction x
evalPending

evalAction :: LPFuzz v c o m => LPAction -> m ()
evalAction :: (LPFuzz v c o m) => LPAction -> m ()
evalAction action = tell (S.singleton (show action)) >> evalAction' action

evalAction' :: LPFuzz v c o m => LPAction -> m ()
evalAction' :: (LPFuzz v c o m) => LPAction -> m ()
evalAction' (AddVariable k) = add k addVariable variables
evalAction' (AddThenRemoveVariable k) = addThenRemove k addVariable deleteVariable variables
evalAction' (AddConstraint k) = add k makeConstraint constraints
Expand All @@ -140,14 +141,14 @@ addThenRemove k create destroy focus = do
Just v -> destroy v >> modifying focus (M.delete k)
Nothing -> add k create focus

makeConstraint :: LPFuzz v c o m => m c
makeConstraint :: (LPFuzz v c o m) => m c
makeConstraint = do
lhs <- chooseExpr
rhs <- chooseExpr
op <- chooseInequality
lhs `op` rhs

chooseExpr :: LPFuzz v c o m => m (Expr v)
chooseExpr :: (LPFuzz v c o m) => m (Expr v)
chooseExpr = do
g <- use randomGen
vs <- use variables
Expand All @@ -157,7 +158,7 @@ chooseExpr = do

pure (esum terms)

chooseInequality :: LPFuzz v c o m => m (Expr v -> Expr v -> m c)
chooseInequality :: (LPFuzz v c o m) => m (Expr v -> Expr v -> m c)
chooseInequality = do
g <- use randomGen
d3 <- liftIO (uniformRM (0 :: Int, 2) g)
Expand All @@ -166,7 +167,7 @@ chooseInequality = do
1 -> pure (.>=.)
_ -> pure (.==.)

makeObjective :: LPFuzz v c o m => m o
makeObjective :: (LPFuzz v c o m) => m o
makeObjective = do
g <- use randomGen
minimizing <- liftIO (uniformM g)
Expand All @@ -185,6 +186,7 @@ makeFuzzTests runner =
describe "Fuzz testing" $ do
prop "finds no failures" $ \seed (LPActions todo) -> do
initState <- liftIO (initLPState seed todo)
runner . execWriterT
runner
. execWriterT
. flip evalStateT initState
$ evalPending
16 changes: 8 additions & 8 deletions math-programming/math-programming.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ library
ghc-options: -Wall
-- Restrictions on transformers due to https://hub.darcs.net/ross/transformers/issue/90
build-depends: base <5
, containers ^>=0.6
, exceptions ^>=0.10
, mtl ^>=2.2
, text ^>=1.2
, transformers ^>=0.5
, containers >=0.6
, exceptions >=0.10
, mtl >=2.2
, text >=1.2
, transformers >=0.5

test-suite math-programming-test-suite
default-language: Haskell2010
Expand All @@ -45,6 +45,6 @@ test-suite math-programming-test-suite
build-depends: math-programming
, base <5
, hspec >=2.8 && <3
, mtl ^>=2.2
, QuickCheck ^>=2.14
, text ^>=1.2
, mtl >=2.2
, QuickCheck >=2.14
, text >=1.2
1 change: 0 additions & 1 deletion math-programming/shell.nix

This file was deleted.

26 changes: 0 additions & 26 deletions nix/sources.json

This file was deleted.

Loading