lazy-search 0.1.1.0 → 0.1.2.0
raw patch · 3 files changed
+16/−10 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Control.Search: infixr 0 ==>
+ Control.Search: infixr 2 |||
+ Control.Search: infixr 3 &&&
+ Data.Coolean: infixr 0 ==>
+ Data.Coolean: infixr 2 |||
+ Data.Coolean: infixr 3 &&&
Files
- lazy-search.cabal +5/−4
- src/Control/Search.hs +10/−6
- src/Data/Coolean.hs +1/−0
lazy-search.cabal view
@@ -1,8 +1,5 @@--- Initial lazy-search.cabal generated by cabal init. For further --- documentation, see http://haskell.org/cabal/users-guide/ - name: lazy-search -version: 0.1.1.0 +version: 0.1.2.0 synopsis: Finds values satisfying a lazy predicate description: This library can be used as a property based testing driver, and more @@ -21,6 +18,10 @@ build-type: Simple -- extra-source-files: cabal-version: >=1.10 + +source-repository head + type: git + location: https://github.com/JonasDuregard/lazy-search library exposed-modules: Data.Coolean, Control.Search
src/Control/Search.hs view
@@ -53,19 +53,22 @@ Unit :: a -> Value a -- A value that can potentially be replaced by a larger value Alt :: a -> Value a -> Minimal a -> Value a + + -- StrictAlt :: a -> Value a -> (Int -> [a]) + instance Show a => Show (Value a) where show v = "("++ repV v ++ ", " ++ show (plainV v) ++ ")" instance Functor Value where - fmap = mkMap - + fmap f a = Map (f (plainV a)) f a + repV :: Value a -> String repV (Unit _) = "1" repV (Pair _ a b) = "("++ repV a ++ ", " ++ repV b ++ ")" repV (Alt _ a _) = "?"++ repV a -repV (Map _ _ v) = "$"++ repV v +repV (Map a f v) = "$"++ repV v plainV :: Value a -> a plainV (Pair a _ _) = a @@ -119,7 +122,9 @@ pair (Pay a) b = Pay (pair a b) pair a (Pay b) = Pay (pair a b) pair (Value f) (Value g) = Value (mkPair f g) - + + naturals = pure 0 <|> pay (fmap (+1) naturals) + aconcat [] = empty aconcat [s] = s aconcat [s1,s2] = s1 <|> s2 @@ -134,8 +139,7 @@ Pay s' -> case extr ss of (ss',Nothing) -> (s':ss',Nothing) (ss',j) -> (s:ss', j) - extr _ = error "internal error" - + extr _ = ([], Nothing) data Observed a = Observed { sizeLeft :: Int, val :: Value a } deriving Functor instance Show a => Show (Observed a) where
src/Data/Coolean.hs view
@@ -54,6 +54,7 @@ (==>) :: (Coolean a, Coolean b) => a -> b -> Cool a ==> b = Not (toCool a <&> Not (toCool b)) +infixr 0 ==> -- | Sequential conjunction. Does not evaluate second operand unless first is True. (!&&) :: (Coolean a, Coolean b) => a -> b -> Cool