-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGen.hs
23 lines (17 loc) · 787 Bytes
/
Gen.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{-# language TemplateHaskell #-}
module Gen where
import Test.QuickCheck
import Syntax
instance Arbitrary Atom where arbitrary = elements $ Atom <$> ["mary","john","bob"]
instance Arbitrary VariableName where
arbitrary = VariableName 0 <$> elements ["X","Y","Z"]
instance Arbitrary Term where
arbitrary = do constr <- elements ['Struct, 'Var, 'Wildcard, 'Cut]
if | constr == 'Struct -> Struct <$> arbitrary @Atom <*> listOf (arbitrary @Term)
| constr == 'Var -> Var <$> arbitrary @VariableName
| constr == 'Wildcard -> pure Wildcard
| constr == 'Cut -> pure (Cut 0)
--instance Arbitrary clause where
--arbitrary = do
--lhs <- arbitrary @Atom
--rhs_ <- listOf