darcs patch: Make Gen an instance of Applicative

Bjorn Bringert bringert at cs.chalmers.se
Tue May 8 17:57:09 EDT 2007


I like this, but I'm afraid the compatibility price might be too  
high. AFAIK, Control.Applicative is only available in base >= 2.0 ,  
which means that QuickCheck 2 wouldn't work with Haskell  
implementations which come with base < 2.0. This means that no  
program which wants to be testable with older implementations can  
switch to QC2.

Is this acceptable instead: return f `ap` a `ap` b `ap` c ? That's  
already possible, right?

/Björn

On May 8, 2007, at 18:38 , Duncan Coutts wrote:

> Thanks to Björn Bringert and Koen Claessen, the QuickCheck 2 darcs  
> repository
> is now hosted at:
>
> darcs get http://darcs.haskell.org/QuickCheck/
>
> 'darcs send' will send patches to the libraries mailing list.
>
> We figured this list is appropriate since QC is a tool that many  
> people depend
> on so getting a wider range of reviewers is good and yet  
> development activity
> isn't likely to be so high that a seperate mailing list would be  
> needed.
>
> Here's one such patch:
>
> Tue May  8 17:32:04 BST 2007  Duncan Coutts  
> <duncan.coutts at worc.ox.ac.uk>
>   * Make Gen an instance of Applicative
>   So we can use the nice syntax: f <$> a <*> b <*> c
>
>
> New patches:
>
> [Make Gen an instance of Applicative
> Duncan Coutts <duncan.coutts at worc.ox.ac.uk>**20070508163204
>  So we can use the nice syntax: f <$> a <*> b <*> c
> ] {
> hunk ./Test/QuickCheck/Gen.hs 17
> +import Control.Applicative (Applicative(..), (<$>))
> hunk ./Test/QuickCheck/Gen.hs 35
> +instance Applicative Gen where
> +  pure x =
> +    MkGen (\_ _ -> x)
> +
> +  MkGen f <*> MkGen x =
> +    MkGen (\r n ->
> +      let (r1,r2) = split r
> +       in f r1 n (x r2 n))
> +
> }
>
> Context:
>
> [Haddock tweak.
> bringert at cs.chalmers.se**20061126234053]
> [Added a version of sampling that returns the test cases
> dpt at math.columbia.edu**20061126220704]
> [Added LICENSE file.
> bringert at cs.chalmers.se**20061126232241]
> [Fixed silly missed use of Positive constructor. Reported by Audrey  
> Tang.
> bringert at cs.chalmers.se**20061124212824]
> [Added README.
> bringert at cs.chalmers.se**20061123144917]
> [Some haddock mark-up fixes to support haddock 0.7.
> bringert at cs.chalmers.se**20061123144831]
> [Removed BUGS.
> bringert at cs.chalmers.se**20061123144204]
> [Changed distribution of NonNegative to 1:5 for 0:everything else  
> (was 9:1).
> bringert at cs.chalmers.se**20061120210126]
> [Added NonZero and reimplemented Positive in terms of NonZero and  
> NonNegative.
> bringert at cs.chalmers.se**20061120205417]
> [Added BUGS file.
> bringert at cs.chalmers.se**20061120205405]
> [Added Integral and Real instances for Positive and NonNegative.
> bringert at cs.chalmers.se**20061120204544]
> [Some haddock tweaks.
> bringert at cs.chalmers.se**20061120112922]
> [More haddock comments.
> bringert at cs.chalmers.se**20061120112532]
> [More haddock and export list fixes.
> bringert at cs.chalmers.se**20061117201830]
> [Added lots of Haddock comments and cleaned up export lists.
> bringert at cs.chalmers.se**20061117200346]
> [Commented out generics import that Haddock choked on.
> bringert at cs.chalmers.se**20061117152818]
> [Removed shrinkSub workarounds for old GHC bugs.
> bringert at cs.chalmers.se**20061117152630]
> [Get rid of the last uses of modules from the haskell98 package,  
> replace with base modules.
> bringert at cs.chalmers.se**20061117152400]
> [Added Cabal build system.
> bringert at cs.chalmers.se**20061117152230]
> [Removed Koen's CVS update script.
> bringert at cs.chalmers.se**20061117151819]
> [Renamed modules to Test.QuickCheck.*.
> bringert at cs.chalmers.se**20061117151417]
> [More fixes to get examples to compile.
> bringert at cs.chalmers.se**20061114164526]
> [Fixed some imports in examples.
> bringert at cs.chalmers.se**20061114163012]
> [Fixed Chalmers/QuickCheck/Monadic.hs to compile with GHC 6.6.
> bringert at cs.chalmers.se**20061114162953]
> [Moved examples to a top-level directory.
> bringert at cs.chalmers.se**20061114160643]
> [Fixed ExSet2 and ExLambda to compile with GHC 6.6.
> bringert at cs.chalmers.se**20061114160531]
> [Comment out generics stuff to compile with GHC 6.6.
> bringert at cs.chalmers.se**20061114160414]
> [Renamed QuickCheck to Chalmers to get module names right.
> bringert at cs.chalmers.se**20061114160326]
> [Tailorization of QuickCheck
> tailor at momo.medic.chalmers.se**20061114165514
>  Import of the upstream sources from the repository
>
>   /users/cs/koen/CvsRoot
>
>  as of revision 2006-05-03 18:37:52 by koen
>
> ]
> Patch bundle hash:
> 133c0e3a886385a943e73a6b7551229f2c07b96c
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries



More information about the Libraries mailing list