speculate 0.2.6 → 0.2.7
raw patch · 3 files changed
+33/−47 lines, 3 files
Files
- README.md +24/−43
- speculate.cabal +2/−2
- tests/test-expr.hs +7/−2
README.md view
@@ -4,7 +4,7 @@ [![Speculate Build Status][build-status]][build-log] [![Speculate on Hackage][hackage-version]][speculate-on-hackage] -Speculate automatically discovers laws about Haskell functions.+Speculate automatically discovers laws about [Haskell] functions. Give Speculate a bunch of Haskell functions and it will discover laws like: * equations, such as `id x == x`;@@ -14,56 +14,24 @@ Speculate is similar to, and inspired by, [QuickSpec]. -Crash Course---------------Install pre-requisites:-- $ cabal install cmdargs- $ cabal install leancheck--Clone and enter the repository:-- $ git clone https://github.com/rudymatela/speculate- $ cd speculate--There are some examples in the `eg` folter. For example `eg/plus-abs.hs`:-- $ cat eg/plus-abs.hs- ...- ...--Compile and run with:-- $ ghc -isrc eg/plus-abs.hs- $ ./eg/plus-abs- ...-- Installing Speculate -------------------- -Pre-requisites are [cmdargs] and [leancheck].-You can install them with:-- $ cabal install cmdargs- $ cabal install leancheck--No `cabal` package has been made yet. For now, clone the repository with:-- $ git clone https://github.com/rudymatela/speculate+To install the [latest Speculate version from Hackage], just: -and compile programs that use it with:+ $ cabal update+ $ cabal install speculate - $ ghc -ipath/to/speculate/src program.hs+Pre-requisites are [cmdargs] and [leancheck].+They should be automatically resolved and installed by [Cabal]. Using Speculate --------------- -Speculate is used as a library: import it, then call the function `speculate`-with relevant arguments. The following program Speculates about the functions-`(+)` and `abs`:+Speculate is used as a library: import it, then call the function [`speculate`]+with relevant arguments. The following program Speculates about the+functions [`(+)`] and [`abs`]: import Test.Speculate @@ -98,7 +66,7 @@ x <= x + 1 -Now, if we add `<=` and `<` as background constants on `args`+Now, if we add [`<=`] and [`<`] as background constants on [`args`] , constants = [ showConstant (0::Int)@@ -153,7 +121,20 @@ [QuickCheck]: https://hackage.haskell.org/package/QuickCheck [cmdargs]: https://hackage.haskell.org/package/cmdargs +[Cabal]: https://www.haskell.org/cabal+[Haskell]: https://www.haskell.org/++[`speculate`]: https://hackage.haskell.org/package/speculate/docs/Test-Speculate.html#v:speculate+[`args`]: https://hackage.haskell.org/package/speculate/docs/Test-Speculate.html#v:args+[`constant`]: https://hackage.haskell.org/package/speculate/docs/Test-Speculate.html#v:constant++[`(+)`]: https://hackage.haskell.org/package/base/docs/Prelude.html#v:-43-+[`abs`]: https://hackage.haskell.org/package/base/docs/Prelude.html#v:abs+[`<=`]: https://hackage.haskell.org/package/base/docs/Prelude.html#v:-60--61-+[`<`]: https://hackage.haskell.org/package/base/docs/Prelude.html#v:-60-+ [build-status]: https://travis-ci.org/rudymatela/speculate.svg?branch=master [build-log]: https://travis-ci.org/rudymatela/speculate [hackage-version]: https://img.shields.io/hackage/v/speculate.svg-[speculate-on-hackage]: https://hackage.haskell.org/package/speculate+[speculate-on-hackage]: https://hackage.haskell.org/package/speculate+[latest Speculate version from Hackage]: https://hackage.haskell.org/package/speculate
speculate.cabal view
@@ -1,5 +1,5 @@ name: speculate-version: 0.2.6+version: 0.2.7 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.6+ tag: v0.2.7 library
tests/test-expr.hs view
@@ -175,11 +175,12 @@ , zero < one , xx < zero +{- -- commenting out as those tests are causing more harm than good. -- If those two ever fail, it is because the instance for Ord TypeRep in -- Data.Typeable has changed. I do rely on this for a "nice" knuth-bendix -- order (by prefering less arity). If this ever changes, I will have to -- explicitly compare type arity on Ord Expr.- -- (update: haha! It has changed from before, and twice!)+ -- (update: haha! It has changed from before, and twice, and thrice!) -- TODO: fix order under GHC <= 7.8 #if __GLASGOW_HASKELL__ < 706 , typeOf ((+) :: Int -> Int -> Int) > typeOf (abs :: Int -> Int)@@ -187,10 +188,14 @@ #elif __GLASGOW_HASKELL__ < 800 , typeOf ((+) :: Int -> Int -> Int) < typeOf (abs :: Int -> Int) , typeOf (abs :: Int -> Int) < typeOf (0 :: Int)-#else+#elif __GLASGOW_HASKELL__ < 802 , typeOf ((+) :: Int -> Int -> Int) > typeOf (abs :: Int -> Int) , typeOf (abs :: Int -> Int) > typeOf (0 :: Int)+#else+ , typeOf ((+) :: Int -> Int -> Int) < typeOf (abs :: Int -> Int)+ , typeOf (abs :: Int -> Int) > typeOf (0 :: Int) #endif+-} , holds n $ \e1 e2 -> e1 `isSub` e2 == (e1 `elem` subexprsV e2)