1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 18:06:14 +03:00

Add an identity law over merge.

This commit is contained in:
Rob Rix 2016-07-26 13:30:09 -04:00
parent 794fffbf47
commit 2ee68cc4b2

View File

@ -26,7 +26,11 @@ spec = parallel $ do
mergeLaws :: forall f g a. (Mergeable f, Alternative g, Eq (g (f a)), Show (f a), Show (g (f a))) => Gen (f a) -> Gen (Blind (a -> g a)) -> Spec
mergeLaws value function = describe "merge" $ do
prop "relationship with sequenceAlt" . forAll ((,) <$> value <*> function) $
prop "identity" . forAll value $
\ a -> merge pure a `shouldBe` (pure a :: g (f a))
let pair = (,) <$> value <*> function
prop "relationship with sequenceAlt" . forAll pair $
\ (a, f) -> merge (getBlind f) a `shouldBe` sequenceAlt (fmap (getBlind f) a)
sequenceAltLaws :: forall f g a. (Mergeable f, Alternative g, Eq (g (f a)), Show (f a), Show (g (f a))) => Gen (f a) -> Gen (Blind (a -> g a)) -> Spec