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:
parent
0dec4c2879
commit
365e84301d
@ -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 _ = []
|
||||
|
Loading…
Reference in New Issue
Block a user