quickcheck icon indicating copy to clipboard operation
quickcheck copied to clipboard

added applicative to num wrappers

Open BebeSparkelSparkel opened this issue 5 years ago • 2 comments
trafficstars

BebeSparkelSparkel avatar Apr 09 '20 19:04 BebeSparkelSparkel

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?

Lysxia avatar Apr 09 '20 21:04 Lysxia

It seemed convenient to be able to do

(|-|) :: (Applicative f, Num a) => f a -> f a -> f a
(|-|) = liftA2 (-)

BebeSparkelSparkel avatar Apr 09 '20 21:04 BebeSparkelSparkel

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!

MaximilianAlgehed avatar Mar 23 '24 11:03 MaximilianAlgehed