module Or where import Data.Semigroup import Test.QuickCheck data Or a b = Fst a | Snd b deriving (Eq, Show) instance Semigroup (Or a b) where (Snd x) <> _ = Snd x _ <> x = x instance (Arbitrary a, Arbitrary b) => Arbitrary (Or a b) where arbitrary = do x <- arbitrary y <- arbitrary frequency [ (1, return $ Fst x), (1, return $ Snd y) ]