darcs patch: Make Gen an instance of Applicative

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

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
* 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
**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@cs.chalmers.se**20061126234053] [Added a version of sampling that returns the test cases dpt@math.columbia.edu**20061126220704] [Added LICENSE file. bringert@cs.chalmers.se**20061126232241] [Fixed silly missed use of Positive constructor. Reported by Audrey Tang. bringert@cs.chalmers.se**20061124212824] [Added README. bringert@cs.chalmers.se**20061123144917] [Some haddock mark-up fixes to support haddock 0.7. bringert@cs.chalmers.se**20061123144831] [Removed BUGS. bringert@cs.chalmers.se**20061123144204] [Changed distribution of NonNegative to 1:5 for 0:everything else (was 9:1). bringert@cs.chalmers.se**20061120210126] [Added NonZero and reimplemented Positive in terms of NonZero and NonNegative. bringert@cs.chalmers.se**20061120205417] [Added BUGS file. bringert@cs.chalmers.se**20061120205405] [Added Integral and Real instances for Positive and NonNegative. bringert@cs.chalmers.se**20061120204544] [Some haddock tweaks. bringert@cs.chalmers.se**20061120112922] [More haddock comments. bringert@cs.chalmers.se**20061120112532] [More haddock and export list fixes. bringert@cs.chalmers.se**20061117201830] [Added lots of Haddock comments and cleaned up export lists. bringert@cs.chalmers.se**20061117200346] [Commented out generics import that Haddock choked on. bringert@cs.chalmers.se**20061117152818] [Removed shrinkSub workarounds for old GHC bugs. bringert@cs.chalmers.se**20061117152630] [Get rid of the last uses of modules from the haskell98 package, replace with base modules. bringert@cs.chalmers.se**20061117152400] [Added Cabal build system. bringert@cs.chalmers.se**20061117152230] [Removed Koen's CVS update script. bringert@cs.chalmers.se**20061117151819] [Renamed modules to Test.QuickCheck.*. bringert@cs.chalmers.se**20061117151417] [More fixes to get examples to compile. bringert@cs.chalmers.se**20061114164526] [Fixed some imports in examples. bringert@cs.chalmers.se**20061114163012] [Fixed Chalmers/QuickCheck/Monadic.hs to compile with GHC 6.6. bringert@cs.chalmers.se**20061114162953] [Moved examples to a top-level directory. bringert@cs.chalmers.se**20061114160643] [Fixed ExSet2 and ExLambda to compile with GHC 6.6. bringert@cs.chalmers.se**20061114160531] [Comment out generics stuff to compile with GHC 6.6. bringert@cs.chalmers.se**20061114160414] [Renamed QuickCheck to Chalmers to get module names right. bringert@cs.chalmers.se**20061114160326] [Tailorization of QuickCheck tailor@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@haskell.org http://www.haskell.org/mailman/listinfo/libraries

On Tue, 2007-05-08 at 23:57 +0200, Bjorn Bringert wrote:
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.
Yeah, I guess that's true. The applicative stuff is of course just pure Haskell code, it could be packaged for older systems that don't have base 2.0. Ironically the intention of putting it into base was to make it more available, not less so. It's a shame that this blocks progress. This would need Cabal configurations to be able to say that we depend on base > 2.0 or a separate Control.Applicative package. Or as people have suggested before, what we really want to say is that we depend on a particular interface and that happens to be provided by base 2.0. But that's such a huge can of worms. Ho hum.
Is this acceptable instead: return f `ap` a `ap` b `ap` c ? That's already possible, right?
Yeah, you can. It's not nearly as nice though and it doesn't let you use the other applicative functions that rely on the type class. Duncan
participants (2)
-
Bjorn Bringert
-
Duncan Coutts