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

Bind in the opposite direction.

This commit is contained in:
Rob Rix 2015-12-11 14:17:04 -05:00
parent 02c19d1d93
commit ed929f07a0

View File

@ -27,9 +27,9 @@ unTerm arbitraryTerm = unfold unpack arbitraryTerm
instance (Eq a, Eq f, Arbitrary a, Arbitrary f) => Arbitrary (Syntax a f) where instance (Eq a, Eq f, Arbitrary a, Arbitrary f) => Arbitrary (Syntax a f) where
shrink syntax = filter (/= syntax) $ shrinkSyntax syntax shrink syntax = filter (/= syntax) $ shrinkSyntax syntax
where shrinkSyntax (Leaf a) = Leaf <$> shrink a where shrinkSyntax (Leaf a) = Leaf <$> shrink a
shrinkSyntax (Indexed i) = Indexed <$> (shrink =<< List.subsequences i) shrinkSyntax (Indexed i) = Indexed <$> (List.subsequences i >>= shrink)
shrinkSyntax (Fixed f) = Fixed <$> (shrink =<< List.subsequences f) shrinkSyntax (Fixed f) = Fixed <$> (List.subsequences f >>= shrink)
shrinkSyntax (Keyed k) = Keyed . Map.fromList <$> (shrink =<< List.subsequences (Map.toList k)) shrinkSyntax (Keyed k) = Keyed . Map.fromList <$> (List.subsequences (Map.toList k) >>= shrink)
instance (Eq a, Eq annotation, Arbitrary a, Arbitrary annotation) => Arbitrary (ArbitraryTerm a annotation) where instance (Eq a, Eq annotation, Arbitrary a, Arbitrary annotation) => Arbitrary (ArbitraryTerm a annotation) where
arbitrary = arbitraryBounded 4 arbitrary = arbitraryBounded 4