packages feed

speculate 0.2.5 → 0.2.6

raw patch · 6 files changed

+70/−10 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

README.md view
@@ -145,7 +145,7 @@ For more examples, see the [eg](eg) and [bench](bench) folders.  Speculate has been subject to a paper, see the-[(Draft) Paper about Speculate (to appear) on Haskell Symposium 2017](https://matela.com.br/paper/speculate.pdf).+[Speculate Paper on Haskell Symposium 2017](https://matela.com.br/paper/speculate.pdf).  [leancheck]: https://hackage.haskell.org/package/leancheck [LeanCheck]: https://hackage.haskell.org/package/leancheck
speculate.cabal view
@@ -1,5 +1,5 @@ name:                speculate-version:             0.2.5+version:             0.2.6 synopsis:            discovery of properties about Haskell functions description:   Speculate automatically discovers laws about Haskell functions.@@ -31,7 +31,7 @@ source-repository this   type:            git   location:        https://github.com/rudymatela/speculate-  tag:             v0.2.5+  tag:             v0.2.6   library
src/Test/Speculate/Expr/Core.hs view
@@ -142,7 +142,8 @@                     hs -> "  (holes: " ++ intercalate ", " (map show hs) ++ ")"  showsPrecExpr :: Int -> Expr -> String -> String-showsPrecExpr d (Constant s _) | atomic s && isInfixedPrefix s = showString $ toPrefix s+showsPrecExpr d (Constant s _) | isInfixedPrefix s = showString $ toPrefix s+showsPrecExpr d (Constant s _) | isNegativeLiteral s = showParen (d > 0) $ showString s showsPrecExpr d (Constant s _) = showParen sp $ showString s   where sp = if atomic s then isInfix s else maybe True (d >) $ outernmostPrec s showsPrecExpr d (Var "" _)     = showString "_" -- a hole
src/Test/Speculate/Utils/String.hs view
@@ -13,6 +13,7 @@   , unquote   , atomic   , outernmostPrec+  , isNegativeLiteral   , isInfix, isPrefix, isInfixedPrefix   , toPrefix   , prec@@ -46,6 +47,12 @@     [l,o,r] | isInfix o -> Just (prec o)     _                   -> Nothing +isNegativeLiteral :: String -> Bool+isNegativeLiteral s | not (atomic s) = False+isNegativeLiteral "-"                = False+isNegativeLiteral ('-':cs)           = all isDigit cs+isNegativeLiteral _                  = False+ -- | Check if a function / operator is infix -- -- > isInfix "foo"   == False@@ -95,8 +102,9 @@  -- | Is the string of the form @`string`@ isInfixedPrefix :: String -> Bool-isInfixedPrefix ('`':cs) = last cs == '`'-isInfixedPrefix _ = False+isInfixedPrefix s | not (atomic s) = False+isInfixedPrefix ('`':cs)           = last cs == '`'+isInfixedPrefix _                  = False  -- | Transform an infix operator into an infix function: --
tests/Test.hs view
@@ -42,15 +42,16 @@   --   Operators are surrounded by dashes.    -- ** Integers-  , zero, one+  , zero, one, two, minusOne, minusTwo   , xx, yy, zz, xx'   , id', abs'-  , (-+-), (-*-), (.-.)+  , (-+-), (-*-), (.-.), (-.-)   , ii, jj, kk, ii'   , negate'   , ff, gg   , ff2, hh2, hh3, hh4, hh5, hh6, hh7   , succ'+  , (-$-)    , idE   , absE@@ -59,6 +60,9 @@   , plusE   , timesE   , minusE+  , commaE+  , ffE+  , ggE    -- ** Booleans   , true, false@@ -281,6 +285,15 @@ one :: Expr one = showConstant (1 :: Int) +two :: Expr+two = showConstant (2 :: Int)++minusOne :: Expr+minusOne = showConstant (-1 :: Int)++minusTwo :: Expr+minusTwo = showConstant (-2 :: Int)+ xx :: Expr -- ex xx = var "x" int @@ -336,6 +349,19 @@ minusE :: Expr minusE = constant "-" ((-) :: Int -> Int -> Int) +(-.-) :: Expr -> Expr -> Expr+e1 -.- e2 = commaE :$ e1 :$ e2++commaE :: Expr+commaE = constant "," ((,) :: Int -> Int -> (Int,Int))++(-$-) :: Expr -> Expr -> Expr+e1 -$- e2 = applyE :$ e1 :$ e2+infixl 6 -$-++applyE :: Expr+applyE = constant "$" (($) :: (Int -> Int) -> Int -> Int)+ ii :: Expr ii = var "i" int @@ -349,10 +375,16 @@ ii' = var "i'" int  ff :: Expr -> Expr-ff = (ffE :$) where ffE = constant "f" (undefined :: Int -> Int)+ff = (ffE :$) +ffE :: Expr+ffE = constant "f" (undefined :: Int -> Int)+ gg :: Expr -> Expr-gg = (ggE :$) where ggE = constant "g" (undefined :: Int -> Int)+gg = (ggE :$)++ggE :: Expr+ggE = constant "g" (undefined :: Int -> Int)  ff2 :: Expr -> Expr -> Expr ff2 e1 e2 = ffE :$ e1 :$ e2
tests/test-expr.hs view
@@ -204,4 +204,23 @@   , show (cc -:- space -:- dd -:- lineBreak -:- ccs)         == "c:' ':d:'\\n':cs :: [Char]"   , show (cc -:- aa -:- bb -:- emptyString) == "c:\"ab\" :: [Char]"   , show (cc -:- aa -:- bb -:- space -:- aa -:- bb -:- emptyString) == "c:\"ab ab\" :: [Char]"++  , show one                     == "1 :: Int"+  , show (minusOne)              == "-1 :: Int"+  , show (one -+- one)           == "1 + 1 :: Int"+  , show (minusOne -+- minusOne) == "(-1) + (-1) :: Int"++  , show (zero -.- one)          == "(0,1) :: (Int,Int)"+  , show (minusOne -.- minusOne) == "(-1,-1) :: (Int,Int)"++  , show (one -:- ll)                     == "[1] :: [Int]"+  , show (zero -:- one -:- ll)            == "[0,1] :: [Int]"+  , show (minusOne -:- ll)                == "[-1] :: [Int]"+  , show (minusOne -:- minusTwo -:- ll)   == "[-1,-2] :: [Int]"+  , show (xx -:- minusTwo -:- yy -:- ll)  == "[x,-2,y] :: [Int]"+  , show (xx -:- minusTwo -:- yy -:- xxs) == "x:(-2):y:xs :: [Int]"++  , show (ffE -$- zero)     == "f $ 0 :: Int"+  , show (ggE -$- xx)       == "g $ x :: Int"+  , show (ffE -$- minusOne) == "f $ (-1) :: Int"   ]