1
1
mirror of https://github.com/github/semantic.git synced 2024-12-11 08:45:48 +03:00

Test that Range <> is associative.

This commit is contained in:
Rob Rix 2018-03-19 09:54:34 -04:00
parent 5cb387836d
commit 1968d3bc16

View File

@ -32,6 +32,13 @@ subtractRange range1 range2 = Range (start range1) (end range1 - rangeLength (Ra
-- Instances
-- $setup
-- >>> import Test.QuickCheck
-- >>> instance Arbitrary Range where arbitrary = Range <$> arbitrary <*> arbitrary
-- $
-- Associativity:
-- prop> \ a b c -> a <> (b <> c) == (a <> b) <> (c :: Range)
instance Semigroup Range where
Range start1 end1 <> Range start2 end2 = Range (min start1 start2) (max end1 end2)