packages feed

monadiccp 0.7.0 → 0.7.1

raw patch · 4 files changed

+34/−21 lines, 4 files

Files

Control/CP/ComposableTransformers.hs view
@@ -8,10 +8,12 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ImpredicativeTypes #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE ScopedTypeVariables #-}  module Control.CP.ComposableTransformers (   solve,    NewBound, +  Bound,   CTransformer,    CForSolver,    CForResult, @@ -242,8 +244,8 @@     | nv > v        = eval (bound tree) es nv     | otherwise     = eval        tree es v   returnCT (CBBST newBound) (BBP v bound) continue exit =-    do bound' <- newBound-       continue $ BBP (v + 1) bound' +    do bound' :: Bound solver <- newBound  +       continue (BBP (v + 1) bound')  -------------------------------------------------------------------------------- -- RESTARTING
Control/CP/FD/Decompose.hs view
@@ -22,7 +22,7 @@ import Data.Set (Set) import qualified Data.Set as Set -import Control.Monad.State.Lazy+import Control.Monad.State.Lazy hiding (state)  import Control.CP.Debug import Data.Expr.Data
Control/CP/FD/FD.hs view
@@ -4,6 +4,8 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE UndecidableInstances #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE Rank2Types #-}  module Control.CP.FD.FD (   module Data.Expr.Sugar,@@ -172,7 +174,7 @@ --        put s { fdsMinimizeTerm = Just q } --        return $ Just q -boundMinimize :: (Show (FDIntTerm s), FDSolver s, EnumTerm s (FDIntTerm s), Integral (TermBaseType s (FDIntTerm s))) => NewBound (FDInstance s)+boundMinimize :: forall s. (Show (FDIntTerm s), FDSolver s, EnumTerm s (FDIntTerm s), Integral (TermBaseType s (FDIntTerm s))) => NewBound (FDInstance s) boundMinimize = do   bound <- getMinimizeTerm   case bound of@@ -182,8 +184,9 @@       case x of         Just val -> do           con <- liftFD $ fdConstrainIntTerm bndvar (toInteger val)-          let f = \x -> (Add (Right con) x)-          return f+          (let f :: Bound (FDInstance s)+               f = \x -> (Add (Right con) x)+           in (return :: Bound (FDInstance s) -> NewBound (FDInstance s)) (f :: Bound (FDInstance s)) :: NewBound (FDInstance s))         _ -> error "bound variable is not assigned"  runFD :: FDSolver s => FDInstance s a -> s a@@ -751,18 +754,27 @@ --      colX v = FDSpecInfoCol { fdspColSpec = an $ colS v, fdspColVar = Just v, fdspColVal = getColVal_ v s, fdspColTypes = Set.fromList $ Map.keys $ colS v }   return (map boolS $ boolData $ egeLinks edge, map intS $ intData $ egeLinks edge, map colS $ colData $ egeLinks edge) -fdSpecInfo_spec :: FDSolver s => ([Either (FDSpecInfoBool s) (FDBoolSpecType s,FDBoolSpec s)],[Either (FDSpecInfoInt s) (FDIntSpecType s,FDIntSpec s)],[Either (FDSpecInfoCol s) (FDColSpecType s,FDColSpec s)]) -> FDSpecInfo s+fdSpecInfo_spec +  :: forall s. FDSolver s +  => ([Either (FDSpecInfoBool s) (FDBoolSpecType s,FDBoolSpec s)]+     ,[Either (FDSpecInfoInt s) (FDIntSpecType s,FDIntSpec s)]+     ,[Either (FDSpecInfoCol s) (FDColSpecType s,FDColSpec s)]) +  -> FDSpecInfo s fdSpecInfo_spec (b,i,c) =-  let fb (Right x) = FDSpecInfoBool { fdspBoolSpec = nt x, fdspBoolVar = Nothing, fdspBoolVal = Nothing, fdspBoolTypes = Set.singleton $ fst x }-      fb (Left x) = x-      fi (Right x) = FDSpecInfoInt  { fdspIntSpec  = nt x, fdspIntVar  = Nothing, fdspIntVal  = Nothing, fdspIntTypes = Set.singleton $ fst x }-      fi (Left x) = x-      fc (Right x) = FDSpecInfoCol  { fdspColSpec  = nt x, fdspColVar  = Nothing, fdspColVal  = Nothing, fdspColTypes = Set.singleton $ fst x }-      fc (Left x) = x-      nt (_,x) Nothing = Just x-      nt (t1,x) (Just t2) | t1==t2 = Just x-      nt _ _ = Nothing-  in (map fb b, map fi i, map fc c)+  (map fb b, map fi i, map fc c)+  where+    fb :: Either (FDSpecInfoBool s) (FDBoolSpecType s, FDBoolSpec s) -> FDSpecInfoBool s+    fb (Left x)  = x+    fb (Right x) = FDSpecInfoBool { fdspBoolSpec = nt x, fdspBoolVar = Nothing, fdspBoolVal = Nothing, fdspBoolTypes = Set.singleton $ fst x }+    fi :: Either (FDSpecInfoInt s) (FDIntSpecType s, FDIntSpec s) -> FDSpecInfoInt s+    fi (Right x) = FDSpecInfoInt  { fdspIntSpec  = nt x, fdspIntVar  = Nothing, fdspIntVal  = Nothing, fdspIntTypes = Set.singleton $ fst x }+    fi (Left x) = x+    fc (Right x) = FDSpecInfoCol  { fdspColSpec  = nt x, fdspColVar  = Nothing, fdspColVal  = Nothing, fdspColTypes = Set.singleton $ fst x }+    fc (Left x) = x+    nt :: forall a b. Eq a => (a,b) -> Maybe a ->  Maybe b+    nt (_,x)  Nothing   = Just x+    nt (t1,x) (Just t2) | t1==t2 = Just x+    nt _      _         = Nothing  -- | A solver needs to be an instance of this FDSolver class in order to -- create an FDInstance around it.
monadiccp.cabal view
@@ -1,15 +1,14 @@ Name:			monadiccp-Version:		0.7.0+Version:		0.7.1 Description:		Monadic Constraint Programming framework License:		BSD3 License-file:		LICENSE Author:			Tom Schrijvers, Pieter Wuille-Maintainer:		tom.schrijvers@cs.kuleuven.be+Maintainer:		tom.schrijvers@ugent.be Build-Type:		Simple Category:		control Synopsis:		Constraint Programming-Homepage:		http://www.cs.kuleuven.be/~toms/MCP/-Bug-reports:		http://trac.haskell.org/monadiccp/+Homepage:		http://users.ugent.be/~tschrijv/MCP/ Cabal-Version:		>=1.6 Extra-Source-Files: 	examples/*.hs lib/*.cpp lib/*.h