1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 08:54:07 +03:00

Use the field accessor to define unTerm.

This commit is contained in:
Rob Rix 2016-05-31 20:17:49 -04:00
parent 50c6c6c4fa
commit 484ed765f0

View File

@ -24,8 +24,7 @@ newtype ArbitraryTerm a annotation = ArbitraryTerm { unArbitraryTerm :: TermF a
deriving (Show, Eq, Generic) deriving (Show, Eq, Generic)
unTerm :: ArbitraryTerm a annotation -> Term a annotation unTerm :: ArbitraryTerm a annotation -> Term a annotation
unTerm = unfold unpack unTerm = unfold unArbitraryTerm
where unpack (ArbitraryTerm (annotation :< syntax)) = annotation :< syntax
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 = scale (`div` 2) $ sized (\ x -> boundedTerm x x) -- first indicates the cube of the max length of lists, second indicates the cube of the max depth of the tree arbitrary = scale (`div` 2) $ sized (\ x -> boundedTerm x x) -- first indicates the cube of the max length of lists, second indicates the cube of the max depth of the tree