generic-random: Generic random generators

[ generics, library, mit, testing ] [ Propose Tags ]

Please see the README below.


[Skip to Readme]
Versions 0.1.0.0, 0.1.1.0, 0.2.0.0, 0.3.0.0, 0.4.0.0, 0.4.1.0, 0.5.0.0, 1.0.0.0, 1.1.0.0, 1.1.0.1, 1.1.0.2
Dependencies ad, base (>=4.8 && <5), containers, hashable, hmatrix, ieee754, MonadRandom, mtl, QuickCheck, transformers, unordered-containers, vector [details]
License MIT
Author Li-yao Xia
Maintainer lysxia@gmail.com
Category Generics, Testing
Home page http://github.com/lysxia/generic-random
Source repo head: git clone https://github.com/lysxia/generic-random
Uploaded by lyxia at Wed Jun 22 17:11:15 UTC 2016
Distributions LTSHaskell:1.1.0.2, NixOS:1.1.0.2, Stackage:1.1.0.2, openSUSE:1.1.0.2
Downloads 2996 total (47 in the last 30 days)
Rating 2.25 (votes: 2) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-06-22 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for generic-random-0.1.1.0

[back to package description]

Generic random generators Hackage Build Status

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 $ generatorPWith [positiveInts]

    positiveInts :: Alias Gen
    positiveInts =
      alias $ \() -> fmap getPositive arbitrary :: Gen Int

    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