Generic random generators
Go to file
2016-05-05 19:37:09 +02:00
bench Update benchmarks 2016-05-05 01:27:08 +02:00
examples Update API 2016-05-04 20:23:31 +02:00
src/Data/Random Update documentation 2016-05-05 19:37:09 +02:00
test Update API 2016-05-04 20:23:31 +02:00
generic-random.cabal Update API 2016-05-04 20:23:31 +02:00
LICENSE Initial commit 2016-04-06 23:34:02 +02:00
README.md Update README 2016-04-29 00:17:42 +02:00
Setup.hs Initial commit 2016-04-06 23:34:02 +02:00

Generic random generators

Define sized random generators for almost any type.

    {-# LANGUAGE DeriveDataTypeable #-}
    import Data.Data
    import Test.QuickCheck
    import Data.Random.Generics

    data Term = Lambda Int Term | App Term Term | Var Int
      deriving (Show, Data)

    instance Arbitrary Term where
      arbitrary = sized (generator asGen)

    main = sample (arbitrary :: Gen Term)
  • Objects of the same size (number of constructors) occur with the same probability (see Duchon et al., references below).
  • Implements rejection sampling and pointing.
  • Works with QuickCheck and MonadRandom.
  • Can be extended or modified with user defined generators.

References