cflp 2009.1.23 → 2009.1.23.1
raw patch · 4 files changed
+32/−16 lines, 4 files
Files
- cflp.cabal +1/−1
- src/CFLP/Strategies.lhs +30/−6
- src/CFLP/Strategies/CallTimeChoice.lhs +0/−8
- src/CFLP/Tests.lhs +1/−1
cflp.cabal view
@@ -1,5 +1,5 @@ Name: cflp-Version: 2009.1.23+Version: 2009.1.23.1 Cabal-Version: >= 1.6 Synopsis: Constraint Functional-Logic Programming in Haskell Description: This package provides combinators for constraint
src/CFLP/Strategies.lhs view
@@ -4,29 +4,53 @@ This module exposes strategies for CFLP by re-exporting them from other modules in this package. +> {-# LANGUAGE+> FlexibleInstances+> #-}+> > module CFLP.Strategies ( >-> (+>), dfs,+> (<+), dfs, limDFS, > > module CFLP.Strategies.DepthFirst,-> module CFLP.Strategies.CallTimeChoice+> module CFLP.Strategies.CallTimeChoice,+> module CFLP.Strategies.DepthCounter,+> module CFLP.Strategies.DepthLimit > > ) where >+> import Control.Monad+> > import CFLP > import CFLP.Strategies.DepthFirst > import CFLP.Strategies.CallTimeChoice+> import CFLP.Strategies.DepthCounter+> import CFLP.Strategies.DepthLimit We provide a combinator `(+>)` to transform a strategy with a strategy transformer (the type is not descriptive, so better ignore it..). -> infixl 5 +>+> infixr 5 <+ >-> (+>) :: (a -> b) -> (b -> c) -> d -> c-> (s +> t) _ = t (s undefined)+> (<+) :: (b -> c) -> (a -> b) -> d -> c+> (t <+ s) _ = t (s undefined) For convenience, we provide shortcuts for useful strategies. > dfs :: c -> CTC (Monadic (UpdateT (StoreCTC c) [])) a-> dfs = dfsWithEvalTimeChoice +> callTimeChoice+> dfs = callTimeChoice <+ dfsWithEvalTimeChoice+>+> limDFS :: c -> CTC (Depth (DepthLim (Monadic+> (UpdateT (StoreCTC (DepthCtx (DepthLimCtx c))) [])))) a+> limDFS = callTimeChoice <+ countDepth <+ limitDepth <+ dfsWithEvalTimeChoice++Finally, we provide instances for the type class `CFLP` that is a+shortcut for the class constraints of CFLP computations.++> instance (MonadPlus m, Enumerable m)+> => CFLP (CTC (Monadic (UpdateT (StoreCTC ()) m)))+>+> instance (MonadPlus m, Enumerable m)+> => CFLP (CTC (Depth (DepthLim (Monadic+> (UpdateT (StoreCTC (DepthCtx (DepthLimCtx ()))) m)))))
src/CFLP/Strategies/CallTimeChoice.lhs view
@@ -32,7 +32,6 @@ > > import Control.Monad >-> import CFLP > import CFLP.Control.Monad.Update > import CFLP.Control.Strategy @@ -147,10 +146,3 @@ > alterNarrowed c n isn > | isJust (lookupChoice n c) = return True > | otherwise = isn--Finally, we provide an instance for the type class `CFLP` that is a-shortcut for the class constraints of CFLP computations.--> instance (MonadPlus m, Enumerable m)-> => CFLP (CTC (Monadic (UpdateT (StoreCTC ()) m)))-
src/CFLP/Tests.lhs view
@@ -26,7 +26,7 @@ > assertResultsLimit :: (Generic a, Show a, Eq a) > => Maybe Int -> Computation a -> [a] -> Assertion > assertResultsLimit limit op expected = do-> actual <- eval (dfs ()) op+> actual <- eval (limDFS ()) op > maybe id take limit actual @?= expected We provide auxiliary assertions `assertResults...` that compute (a