nick8325 / nick8325/quickcheck

Relax superclasses for instance Arbitrary Compose

Open Beginner friendly
#481 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haskell
Stars
790
Forks
130
Avg merge
16h 41m
Merged PRs (30d)
2

Description

Currently we define
https://github.com/nick8325/quickcheck/blob/3c2d0d87d4b9f457a586b1cde6d1d3ac03d862bf/src/Test/QuickCheck/Arbitrary.hs#L1016-L1018

That's more restrictive than it can be, it would be nice to relax the constraint to Arbitrary (f (g a)) as in

instance Arbitrary (f (g a)) => Arbitrary (Compose f g a) where 
  arbitrary = Compose <$> arbitrary
  shrink (Compose x) = map Compose (shrink x)

This would bring the approach in line with how base defines all other instances for Compose:

instance Num (f (g a)) => Num (Compose f g a) 	
instance Read (f (g a)) => Read (Compose f g a) 	
instance Fractional (f (g a)) => Fractional (Compose f g a) 	
instance Integral (f (g a)) => Integral (Compose f g a) 	
instance Real (f (g a)) => Real (Compose f g a) 	
instance RealFrac (f (g a)) => RealFrac (Compose f g a) 	
instance Show (f (g a)) => Show (Compose f g a)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/Test/QuickCheck/Arbitrary.hs at the existing Compose Arbitrary instance around lines 1016-1018, and compare its constraint with the Compose instances in base referenced by the issue. Relax the constraint as described, then run the repository test suite and confirm that Compose values can use the broader Arbitrary instance without regressions.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
testing
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.