@@ -61,7 +61,7 @@ import Data.Unfoldable.MaybeEmpty
61
61
)
62
62
63
63
import Data.Maybe (Maybe (..), isJust , isNothing )
64
- import Control.Alternative ((<|>), guard , empty , class Alternative , class Alt )
64
+ import Control.Alternative ((<|>), guard , empty , class Alternative , class Plus , class Alt )
65
65
import Data.Enum (class Enum , class BoundedEnum , succ , pred , upFrom , downFrom , upFromIncluding , enumFromTo )
66
66
import Data.Tuple (snd )
67
67
import Data.Tuple.Nested ((/\), type (/\))
@@ -216,7 +216,7 @@ appendSuite = describe "Semigroup and Alternative" do
216
216
qc \(a :: Trivial1 Char ) (b :: Trivial Char ) -> arrgh1 (a `append1` b) === arrgh1 a <|> arrgh b
217
217
it " append1' agrees with Alt Array" do
218
218
qc \(a :: Trivial Char ) (b :: Trivial1 Char ) -> arrgh1 (a `append1'` b) === arrgh a <|> arrgh1 b
219
- genericAlternativeLaws " Trivial" qc (Proxy :: Proxy (Trivial Int ))
219
+ genericPlusLaws " Trivial" qc (Proxy :: Proxy (Trivial Int ))
220
220
genericAltLaws " Trivial1" qc (Proxy :: Proxy (Trivial1 Int ))
221
221
genericAlternativeLaws " MaybeEmpty NonEmptyList" qc (Proxy :: Proxy (MaybeEmpty NEL.NonEmptyList Int ))
222
222
@@ -234,16 +234,16 @@ genericAltLaws name qc _ = describe ("Alt " <> name <> " laws") do
234
234
it " Distributivity: f <$> (x <|> y) ≡ (f <$> x) <|> (f <$> y)" do
235
235
qc \(f :: a -> a ) (x :: t a ) y -> f <$> (x <|> y) === (f <$> x) <|> (f <$> y)
236
236
237
- genericAlternativeLaws :: forall t a .
237
+ genericPlusLaws :: forall t a .
238
238
Eq (t a ) =>
239
239
Show (t a ) =>
240
- Alternative t =>
240
+ Plus t =>
241
241
Arbitrary a =>
242
242
Coarbitrary a =>
243
243
Arbitrary (t a ) =>
244
244
Arbitrary (t (a -> a )) =>
245
245
String -> (forall p . Testable p => p -> Aff Unit ) -> Proxy (t a ) -> Spec Unit
246
- genericAlternativeLaws name qc proxy = do
246
+ genericPlusLaws name qc proxy = do
247
247
genericAltLaws name qc proxy
248
248
describe (" Plus " <> name <> " laws" ) do
249
249
it " Left identity: empty <|> x ≡ x" do
@@ -252,6 +252,19 @@ genericAlternativeLaws name qc proxy = do
252
252
qc \(x :: t a ) -> x <|> empty === x
253
253
it " Annihilation: f <$> empty ≡ empty" do
254
254
qc \(f :: a -> a ) -> f <$> empty === (empty :: t a )
255
+
256
+ genericAlternativeLaws :: forall t a .
257
+ Eq (t a ) =>
258
+ Show (t a ) =>
259
+ Alternative t =>
260
+ Arbitrary a =>
261
+ Coarbitrary a =>
262
+ Arbitrary (t a ) =>
263
+ Arbitrary (t (a -> a )) =>
264
+ String -> (forall p . Testable p => p -> Aff Unit ) -> Proxy (t a ) -> Spec Unit
265
+ genericAlternativeLaws name qc proxy = do
266
+ genericAltLaws name qc proxy
267
+ genericPlusLaws name qc proxy
255
268
describe (" Alternative " <> name <> " laws" ) do
256
269
it " Distributivity: (f <|> g) <*> x ≡ (f <*> x) <|> (g <*> x)" do
257
270
qc \(f :: t (a -> a )) g x -> (f <|> g) <*> x === (f <*> x) <|> (g <*> x)
0 commit comments