Skip to content

Instantly share code, notes, and snippets.

@joshcough
Created August 26, 2013 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshcough/6342442 to your computer and use it in GitHub Desktop.
Save joshcough/6342442 to your computer and use it in GitHub Desktop.
instance Arbitrary PatPath where
arbitrary = oneof [ pure LeafPP
, FieldPP <$> arbitrary <*> arbitrary
, ArgPP <$> arbitrary <*> arbitrary
]
instance Arbitrary JavaLike where
arbitrary = oneof [
Method <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary,
Constructor <$> arbitrary <*> arbitrary,
Value <$> arbitrary <*> arbitrary <*> arbitrary
]
instance Arbitrary Foreign where
arbitrary = oneof [ JavaLike <$> arbitrary , JavaLike <$> arbitrary ]
instance Arbitrary HardCore where
arbitrary = oneof [
Super <$> arbitrary,
Slot <$> arbitrary,
Core.Lit <$> arbitrary,
PrimOp <$> arbitrary,
Foreign <$> arbitrary,
Error <$> arbitrary
]
instance Arbitrary a => Arbitrary (Core a) where
arbitrary = sized core' where
core' 0 = oneof [ Core.Var <$> arbitrary, HardCore <$> arbitrary ]
core' n = smaller $ oneof [
Core.Var <$> arbitrary,
HardCore <$> arbitrary,
Core.App <$> arbitrary <*> arbitrary,
Core.Lam <$> arbitrary <*> arbitrary,
Core.Let <$> arbitrary <*> arbitrary,
Core.Case <$> arbitrary <*> arbitrary <*> arbitrary,
Core.Dict <$> arbitrary <*> arbitrary,
Core.LamDict <$> arbitrary,
Core.AppDict <$> arbitrary <*> arbitrary
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment