{"id":26264774,"url":"https://github.com/jonathanknowles/quickcheck-monoid-subclasses","last_synced_at":"2025-10-04T15:41:52.446Z","repository":{"id":65056256,"uuid":"512335166","full_name":"jonathanknowles/quickcheck-monoid-subclasses","owner":"jonathanknowles","description":"Support for testing instances of classes defined in the monoid-subclasses library.","archived":false,"fork":false,"pushed_at":"2025-04-04T18:30:55.000Z","size":3313,"stargazers_count":1,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-30T14:28:37.317Z","etag":null,"topics":["haskell","instances","monoid-subclasses","quickcheck","testing"],"latest_commit_sha":null,"homepage":"https://hackage.haskell.org/package/quickcheck-monoid-subclasses","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonathanknowles.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,"zenodo":null}},"created_at":"2022-07-10T03:26:00.000Z","updated_at":"2025-04-14T17:54:11.000Z","dependencies_parsed_at":"2023-02-13T00:00:40.991Z","dependency_job_id":"8429a6a5-ed92-46a2-b4f7-bd94e503e527","html_url":"https://github.com/jonathanknowles/quickcheck-monoid-subclasses","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanknowles%2Fquickcheck-monoid-subclasses","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanknowles%2Fquickcheck-monoid-subclasses/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanknowles%2Fquickcheck-monoid-subclasses/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanknowles%2Fquickcheck-monoid-subclasses/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonathanknowles","download_url":"https://codeload.github.com/jonathanknowles/quickcheck-monoid-subclasses/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251721211,"owners_count":21632785,"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":["haskell","instances","monoid-subclasses","quickcheck","testing"],"created_at":"2025-03-14T02:17:59.127Z","updated_at":"2025-10-04T15:41:47.405Z","avatar_url":"https://github.com/jonathanknowles.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `quickcheck-monoid-subclasses`\n\n\u003ca href=\"http://jonathanknowles.net/quickcheck-monoid-subclasses/\"\u003e\u003cimg src=\"https://img.shields.io/badge/API-Documentation-green\" /\u003e\u003c/a\u003e\n\n## Overview\n\nThe `quickcheck-monoid-subclasses` library provides:\n- [QuickCheck](https://hackage.haskell.org/package/QuickCheck) support for testing instances of type classes defined in the [`monoid-subclasses`](https://hackage.haskell.org/package/monoid-subclasses) library.\n- Compatibility with the [`quickcheck-classes`](https://hackage.haskell.org/package/quickcheck-classes) library.\n- Reusable properties for type class laws, in the form of [`Laws`](https://hackage.haskell.org/package/quickcheck-classes/docs/Test-QuickCheck-Classes.html#t:Laws) definitions.\n\n## Usage\n\nIn general, usage is identical to that of the [`quickcheck-classes`](https://hackage.haskell.org/package/quickcheck-classes) library. If you're already familiar with [`quickcheck-classes`](https://hackage.haskell.org/package/quickcheck-classes), then using this library should be straightforward.\n\n### Testing laws for a single type class\n\nTo test that the laws of a particular class hold for a particular type, use the [`lawsCheck`](https://hackage.haskell.org/package/quickcheck-classes/docs/Test-QuickCheck-Classes.html#t:lawsCheck) function with the [`Laws`](https://hackage.haskell.org/package/quickcheck-classes/docs/Test-QuickCheck-Classes.html#t:Laws) definition for the class you wish to test.\n\n\u003e #### :stars: Example\n\u003e\n\u003e To test that the [`Monus`](https://hackage.haskell.org/package/monoid-subclasses/docs/Data-Monoid-Monus.html#t:Monus) laws hold for the [`Sum`](https://hackage.haskell.org/package/base/docs/Data-Monoid.html#t:Sum) [`Natural`](https://hackage.haskell.org/package/base/docs/Numeric-Natural.html#t:Natural) type:\n\u003e\n\u003e ```hs\n\u003e import Data.Monoid (Sum)\n\u003e import Data.Proxy (Proxy (Proxy))\n\u003e import Numeric.Natural (Natural)\n\u003e import Test.QuickCheck.Classes (lawsCheck)\n\u003e import Test.QuickCheck.Classes.Monoid.Monus (monusLaws)\n\u003e\n\u003e lawsCheck (monusLaws (Proxy :: Proxy (Sum Natural)))\n\u003e ```\n\u003e\n\u003e If all tests pass, you should see output similar to:\n\u003e\n\u003e ```hs\n\u003e Monus: axiom1 +++ OK, passed 100 tests.\n\u003e Monus: axiom2 +++ OK, passed 100 tests.\n\u003e Monus: axiom3 +++ OK, passed 100 tests.\n\u003e Monus: axiom4 +++ OK, passed 100 tests.\n\u003e Monus: stripPrefixOverlap +++ OK, passed 100 tests.\n\u003e Monus: stripSuffixOverlap +++ OK, passed 100 tests.\n\u003e ```\n\n### Testing laws for multiple type classes\n\nTo test that the laws of __multiple__ classes hold for a particular type, use the [`lawsCheckOne`](https://hackage.haskell.org/package/quickcheck-classes/docs/Test-QuickCheck-Classes.html#t:lawsCheckOne) function with the [`Laws`](https://hackage.haskell.org/package/quickcheck-classes/docs/Test-QuickCheck-Classes.html#t:Laws) definitions for the classes you wish to test.\n\n\u003e #### :stars: Example\n\u003e\n\u003e To test that the [`Sum`](https://hackage.haskell.org/package/base/docs/Data-Monoid.html#t:Sum) [`Natural`](https://hackage.haskell.org/package/base/docs/Numeric-Natural.html#t:Natural) type satisfies the laws of [`Semigroup`](https://hackage.haskell.org/package/base/docs/Data-Semigroup.html#t:Semigroup) and its subclasses:\n\u003e\n\u003e ```hs\n\u003e import Data.Monoid (Sum)\n\u003e import Data.Proxy (Proxy (Proxy))\n\u003e import Numeric.Natural (Natural)\n\u003e import Test.QuickCheck.Classes\n\u003e import Test.QuickCheck.Classes.Monoid.GCD\n\u003e import Test.QuickCheck.Classes.Monoid.LCM\n\u003e import Test.QuickCheck.Classes.Monoid.Monus\n\u003e import Test.QuickCheck.Classes.Monoid.Null\n\u003e import Test.QuickCheck.Classes.Semigroup.Cancellative\n\u003e import Test.QuickCheck.Classes.Semigroup.Factorial\n\u003e\n\u003e lawsCheckOne (Proxy :: Proxy (Sum Natural))\n\u003e     [ cancellativeLaws\n\u003e     , commutativeLaws\n\u003e     , distributiveGCDMonoidLaws\n\u003e     , distributiveLCMMonoidLaws\n\u003e     , factorialLaws\n\u003e     , factorialMonoidLaws\n\u003e     , gcdMonoidLaws\n\u003e     , lcmMonoidLaws\n\u003e     , leftCancellativeLaws\n\u003e     , leftDistributiveGCDMonoidLaws\n\u003e     , leftGCDMonoidLaws\n\u003e     , leftReductiveLaws\n\u003e     , monoidLaws\n\u003e     , monoidNullLaws\n\u003e     , monusLaws\n\u003e     , overlappingGCDMonoidLaws\n\u003e     , positiveMonoidLaws\n\u003e     , reductiveLaws\n\u003e     , rightCancellativeLaws\n\u003e     , rightDistributiveGCDMonoidLaws\n\u003e     , rightGCDMonoidLaws\n\u003e     , rightReductiveLaws\n\u003e     , semigroupLaws\n\u003e     , stableFactorialLaws\n\u003e     ]\n\u003e ```\n\n## Subclasses and superclasses\n\nEach of the [`Laws`](https://hackage.haskell.org/package/quickcheck-classes/docs/Test-QuickCheck-Classes.html#t:Laws) definitions provided by this library corresponds to exactly __one__ type class, and includes __just__ the laws for that class. Laws for subclasses and superclasses are __not__ automatically included. Therefore, you'll need to __explicitly__ test the laws of every single class you wish to cover.\n\n## Coverage checks\n\nThis library includes __coverage checks__ to ensure that important cases are covered, and to reduce the probability of test passes that are false positives. These coverage checks are performed automatically.\n\nTo increase coverage of interesting and important cases, this library also checks that laws hold for __combinations__ of generated arbitrary values.\n\n\u003e #### :stars: Example\n\u003e\n\u003e Suppose we are testing the following law:\n\u003e\n\u003e ```hs\n\u003e isPrefixOf a b == isJust (stripPrefix a b)\n\u003e ```\n\u003e\n\u003e This library will also test that the following __derived__ laws hold:\n\u003e\n\u003e ```hs\n\u003e isPrefixOf a (a \u003c\u003e a) == isJust (stripPrefix a (a \u003c\u003e a))\n\u003e isPrefixOf a (a \u003c\u003e b) == isJust (stripPrefix a (a \u003c\u003e b))\n\u003e isPrefixOf a (b \u003c\u003e a) == isJust (stripPrefix a (b \u003c\u003e a))\n\u003e ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanknowles%2Fquickcheck-monoid-subclasses","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonathanknowles%2Fquickcheck-monoid-subclasses","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanknowles%2Fquickcheck-monoid-subclasses/lists"}