1
1
mirror of https://github.com/github/semantic.git synced 2024-12-24 23:42:31 +03:00

Add an Arbitrary instance for Category.

This commit is contained in:
Rob Rix 2016-06-23 16:29:19 -04:00
parent 0dec4c2879
commit 365e84301d

View File

@ -3,6 +3,7 @@ module Category where
import Prologue
import Data.Hashable
import Data.String
import Test.QuickCheck
-- | A standardized category of AST node. Used to determine the semantics for
-- | semantic diffing and define comparability of nodes.
@ -35,3 +36,21 @@ data Category
-- Instances
instance Hashable Category
instance Arbitrary Category where
arbitrary = oneof
[ pure Program
, pure Error
, pure BinaryOperator
, pure DictionaryLiteral
, pure Pair
, pure FunctionCall
, pure StringLiteral
, pure IntegerLiteral
, pure SymbolLiteral
, pure ArrayLiteral
, Other <$> arbitrary
]
shrink (Other s) = Other <$> shrink s
shrink _ = []