nick8325 / quickcheck

Automatic testing of Haskell programs.
Other
713 stars 119 forks source link

added applicative to num wrappers #291

Closed BebeSparkelSparkel closed 5 months ago

Lysxia commented 4 years ago

These instances seem weird to me, including the already existing Functors. We shouldn't add them "just because we can". Do you have a use case for these?

My objection is that it's fishy that we can even write fmap negate (Positive 1), which equals Positive (-1). The constructor might be exposed anyway, but that is trumped by the convenience of the way they're actually used, by pattern-matching in a lambda: \(Positive x) -> ....

Is there another use for these wrappers that makes sense?

BebeSparkelSparkel commented 4 years ago

It seemed convenient to be able to do

(|-|) :: (Applicative f, Num a) => f a -> f a -> f a
(|-|) = liftA2 (-)
MaximilianAlgehed commented 5 months ago

There appears to be no clear use-case for this and the PR has been stale for several years. I'm going to close this but feel free to open this PR again with a compelling example of where to use this and we can have another look!