The generic-random package

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain]

Please see README.md


[Skip to ReadMe]

Properties

Versions0.1.0.0, 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
Change logNone available
Dependenciesad, base (>=4.8 && <5), containers, hashable, hmatrix, ieee754, MonadRandom, mtl, QuickCheck, transformers, unordered-containers, vector [details]
LicenseMIT
AuthorLi-yao Xia
Maintainerlysxia@gmail.com
CategoryGenerics, Testing
Home pagehttp://github.com/lysxia/generic-random
Source repositoryhead: git clone https://github.com/githubuser/generic-random
UploadedTue May 17 15:43:26 UTC 2016 by lyxia

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees


Readme for generic-random-0.1.0.0

[back to package description]

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

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

    main = sample (arbitrary :: Gen Term)

References