{"id":16313982,"url":"https://github.com/lysxia/generic-random","last_synced_at":"2025-07-13T01:37:50.574Z","repository":{"id":6894283,"uuid":"55642290","full_name":"Lysxia/generic-random","owner":"Lysxia","description":"Generic random generators","archived":false,"fork":false,"pushed_at":"2023-03-14T01:05:58.000Z","size":292,"stargazers_count":81,"open_issues_count":6,"forks_count":6,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-07-13T01:37:48.699Z","etag":null,"topics":["arbitrary","generics","haskell","quickcheck","random-generation","testing"],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Lysxia.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-06T21:37:34.000Z","updated_at":"2024-01-19T13:13:19.000Z","dependencies_parsed_at":"2024-06-21T05:44:20.385Z","dependency_job_id":"5912830f-3e75-4bcc-8931-e9f389bd6765","html_url":"https://github.com/Lysxia/generic-random","commit_stats":{"total_commits":270,"total_committers":4,"mean_commits":67.5,"dds":0.337037037037037,"last_synced_commit":"6ec383674116e4c86d6fceb102854993d5bb4f08"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/Lysxia/generic-random","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lysxia%2Fgeneric-random","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lysxia%2Fgeneric-random/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lysxia%2Fgeneric-random/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lysxia%2Fgeneric-random/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lysxia","download_url":"https://codeload.github.com/Lysxia/generic-random/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lysxia%2Fgeneric-random/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265080033,"owners_count":23708102,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arbitrary","generics","haskell","quickcheck","random-generation","testing"],"created_at":"2024-10-10T21:52:52.004Z","updated_at":"2025-07-13T01:37:50.553Z","avatar_url":"https://github.com/Lysxia.png","language":"Haskell","readme":"Generic random generators [![Hackage](https://img.shields.io/hackage/v/generic-random.svg)](https://hackage.haskell.org/package/generic-random) [![Build Status](https://github.com/Lysxia/generic-random/actions/workflows/ci.yml/badge.svg)](https://github.com/Lysxia/generic-random/actions/workflows/ci.yml)\n=========================\n\nGeneric random generators\nto implement `Arbitrary` instances for [QuickCheck](https://hackage.haskell.org/package/QuickCheck)\n\nAutomating the `arbitrary` boilerplate also ensures that when a type changes to\nhave more or fewer constructors, then the generator either fixes itself to\ngenerate that new case (when using the `uniform` distribution) or causes a\ncompilation error so you remember to fix it (when using an explicit\ndistribution).\n\nThis package also offers a simple (optional) strategy to ensure termination for\nrecursive types:\nmake `Test.QuickCheck.Gen`'s size parameter decrease at every recursive call;\nwhen it reaches zero, sample directly from a trivially terminating generator\ngiven explicitly (`genericArbitraryRec` and `withBaseCase`) or implicitly\n(`genericArbitrary'`).\n\nExample\n-------\n\n```haskell\n{-# LANGUAGE DeriveGeneric #-}\n\nimport GHC.Generics (Generic)\nimport Test.QuickCheck\nimport Generic.Random\n\ndata Tree a = Leaf | Node (Tree a) a (Tree a)\n  deriving (Show, Generic)\n\ninstance Arbitrary a =\u003e Arbitrary (Tree a) where\n  arbitrary = genericArbitraryRec uniform `withBaseCase` return Leaf\n\n-- Equivalent to\n-- \u003e arbitrary =\n-- \u003e   sized $ \\n -\u003e\n-- \u003e     if n == 0 then\n-- \u003e       return Leaf\n-- \u003e     else\n-- \u003e       oneof\n-- \u003e         [ return Leaf\n-- \u003e         , resize (n `div` 3) $\n-- \u003e             Node \u003c$\u003e arbitrary \u003c*\u003e arbitrary \u003c*\u003e arbitrary\n-- \u003e         ]\n\nmain :: IO ()\nmain = sample (arbitrary :: Gen (Tree ()))\n```\n\nRelated\n-------\n\n- The following two packages also derive random generators, but only with a uniform\n  distribution of constructors:\n\n    + [quickcheck-arbitrary-template](https://hackage.haskell.org/package/quickcheck-arbitrary-template) (TH)\n    + [generic-arbitrary](https://hackage.haskell.org/package/generic-arbitrary-0.1.0) (GHC Generics)\n\n- [testing-feat](http://hackage.haskell.org/package/testing-feat):\n  derive enumerations for algebraic data types, which can be turned into random generators (TH).\n\n- [boltzmann-samplers](https://hackage.haskell.org/package/boltzmann-samplers):\n  derive Boltzmann samplers (SYB).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flysxia%2Fgeneric-random","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flysxia%2Fgeneric-random","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flysxia%2Fgeneric-random/lists"}