minizinc-process 0.1.4.0 → 0.1.4.1
raw patch · 5 files changed
+31/−3 lines, 5 filesdep ~base
Dependency ranges changed: base
Files
- CHANGELOG.md +4/−0
- README.md +1/−1
- minizinc-process.cabal +2/−2
- src/Process/Minizinc/TH.hs +2/−0
- test/Test.hs +22/−0
CHANGELOG.md view
@@ -2,6 +2,10 @@ ## Unreleased changes +## 0.1.4.1 -- 2020-11-12++* Improve TemplateHaskell to arrays of floats and arrays of bools.+ ## 0.1.4.0 -- 2020-11-12 * Add primitive TemplateHaskell generation of interface types.
README.md view
@@ -114,7 +114,7 @@ ```minizinc int: x;-array[1..2] of int: y;+array[1..2,1..2] of int: y; var int: z; ...
minizinc-process.cabal view
@@ -4,7 +4,7 @@ -- http://haskell.org/cabal/users-guide/ name: minizinc-process-version: 0.1.4.0+version: 0.1.4.1 synopsis: A set of helpers to call minizinc models. description: MiniZinc is a language and a toolchain to solve discrete optimization problems. This package provides simple wrappers around the MiniZinc executable to pass inputs and read outputs. homepage: https://github.com/lucasdicioccio/minizinc-process#readme@@ -47,7 +47,7 @@ test-suite minizinc-process-tests-hedghehog main-is: Test.hs type: exitcode-stdio-1.0- build-depends: base >=4.13 && <4.14+ build-depends: base >=4.10 && <4.14 , aeson , minizinc-process , hashable
src/Process/Minizinc/TH.hs view
@@ -49,6 +49,8 @@ typeFor (TypeInfo "bool" False Nothing) = ConT (mkName "Bool") typeFor (TypeInfo "float" False Nothing) = ConT (mkName "Float") typeFor (TypeInfo "int" False (Just n)) = nestedlist n $ ConT (mkName "Int")+ typeFor (TypeInfo "bool" False (Just n)) = nestedlist n $ ConT (mkName "Bool")+ typeFor (TypeInfo "float" False (Just n)) = nestedlist n $ ConT (mkName "Float") typeFor typedecl = error $ "unsupported type info when generating Haskell code from MiniZinc files: " <> show typedecl nestedlist 0 ty = ty
test/Test.hs view
@@ -1,9 +1,12 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE DeriveAnyClass #-} module Main where import Data.Function ((&))+import Data.Maybe (isJust) import qualified Data.List as List import Data.Aeson (FromJSON(..), ToJSON(..), (.=), (.:)) import qualified Data.Aeson as Aeson@@ -16,9 +19,14 @@ import qualified Hedgehog.Range as Range import Test.Hspec (describe, it, hspec) import Test.Hspec.Hedgehog (hedgehog)+import GHC.Generics (Generic)+import Data.Aeson (FromJSON, ToJSON) import Process.Minizinc+import Process.Minizinc.TH +genModelData "Test002" "models/test002_04.mzn"+ data Input001 = Input001 { input001X :: Int } deriving (Show,Eq,Ord) instance Hashable Input001 where@@ -77,6 +85,13 @@ isExhaustive (Exhausted a) = True isExhaustive _ = False +mzncall_t002_04 = do+ let mzn = simpleMiniZinc @Test002Input @Test002Output "models/test002_04.mzn" 1000 Gecode+ let input = Test002Input 10 True 1.2 [1,2] [True,True] [0.2,0.3] [[1,2], [3,4]]+ outy <- liftIO $ runLastMinizincJSON mzn input+ liftIO $ cleanTmpFile mzn input+ assert $ isJust outy+ prop_mzncall_t001_01 :: Property prop_mzncall_t001_01 = property mzncall_t001_01@@ -89,6 +104,10 @@ prop_mzncall_t001_03 = property mzncall_t001_03 +prop_mzncall_t002_04 :: Property+prop_mzncall_t002_04 =+ property mzncall_t002_04+ tests :: IO Bool tests = checkParallel $$(discover) @@ -101,3 +120,6 @@ mzncall_t001_02 it "should find seven satisfiable answers to y in [x-3 .. x+3]" $ hedgehog $ do mzncall_t001_03+ describe "autogenerated interface" $ do+ it "should map stuff" $ hedgehog $ do+ mzncall_t002_04