{"id":18464677,"url":"https://github.com/norfairking/validity","last_synced_at":"2025-05-15T10:01:29.343Z","repository":{"id":9786123,"uuid":"62999249","full_name":"NorfairKing/validity","owner":"NorfairKing","description":"Validity and validity-based testing","archived":false,"fork":false,"pushed_at":"2025-05-09T07:09:01.000Z","size":1514,"stargazers_count":160,"open_issues_count":4,"forks_count":31,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-09T07:43:16.505Z","etag":null,"topics":["explicit-invariants","invalid-values","invariants","sanity-test","validity"],"latest_commit_sha":null,"homepage":"https://www.youtube.com/watch?v=eIs9qNh17SM","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/NorfairKing.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"custom":"https://cs-syd.eu/support","github":["NorfairKing"]}},"created_at":"2016-07-10T13:11:41.000Z","updated_at":"2025-02-12T05:57:52.000Z","dependencies_parsed_at":"2024-06-19T00:04:27.672Z","dependency_job_id":"d28062f5-b922-4506-adc5-335144e5dfac","html_url":"https://github.com/NorfairKing/validity","commit_stats":{"total_commits":650,"total_committers":23,"mean_commits":28.26086956521739,"dds":0.5538461538461539,"last_synced_commit":"512aea6e0a112f5df09cc0b08f7fceffb122abc6"},"previous_names":[],"tags_count":155,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NorfairKing%2Fvalidity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NorfairKing%2Fvalidity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NorfairKing%2Fvalidity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NorfairKing%2Fvalidity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NorfairKing","download_url":"https://codeload.github.com/NorfairKing/validity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254319715,"owners_count":22051072,"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":["explicit-invariants","invalid-values","invariants","sanity-test","validity"],"created_at":"2024-11-06T09:10:44.502Z","updated_at":"2025-05-15T10:01:28.716Z","avatar_url":"https://github.com/NorfairKing.png","language":"Haskell","funding_links":["https://cs-syd.eu/support","https://github.com/sponsors/NorfairKing"],"categories":[],"sub_categories":[],"readme":"# Validity and validity-based testing\n\n## Why?\n\n\u003e to make writing correct software cheaper.\n\n- Free generators\n- Free shrinking\n- Cheap properties\n\n### Cheap properties\n\n- Property Combinators:\n\n``` haskell\nspecify \"inverse functions\" $ inverseFunctions (+1) (-1)\nspecify \"equivalent functions\" $ equivalent ((+ 1) . (- 1)) id\nspecify \"transitivity\" $ transitivity ((\u003e) :: Int -\u003e Int -\u003e Bool)\nspecify \"symmetry\" $ symmetry ((==) :: Int -\u003e Int -\u003e Bool)\n```\n\n- Test suite combinators:\n\n``` haskell\nordSpec @Int\n```\n\n```\n  Ord Int\n    (\u003c=) :: Int -\u003e Int -\u003e Bool\n      is reflexive for \"even Int\"'s\n        +++ OK, passed 100 tests.\n      is antisymmetric for \"even Int\"'s\n        +++ OK, passed 100 tests.\n      is transitive for \"even Int\"'s\n        +++ OK, passed 100 tests.\n      is equivalent to (\\a b -\u003e compare a b /= GT) for \"even Int\"'s\n        +++ OK, passed 100 tests.\n    (\u003e=) :: Int -\u003e Int -\u003e Bool\n      is reflexive for \"even Int\"'s\n        +++ OK, passed 100 tests.\n      is antisymmetric for \"even Int\"'s\n        +++ OK, passed 100 tests.\n      is transitive for \"even Int\"'s\n        +++ OK, passed 100 tests.\n      is equivalent to (\\a b -\u003e compare a b /= LT) for \"even Int\"'s\n        +++ OK, passed 100 tests.\n    (\u003c) :: Int -\u003e Int -\u003e Bool\n      is antireflexive for \"even Int\"'s\n        +++ OK, passed 100 tests.\n      is transitive for \"even Int\"'s\n        +++ OK, passed 100 tests.\n      is equivalent to (\\a b -\u003e compare a b == LT) for \"even Int\"'s\n        +++ OK, passed 100 tests.\n    (\u003e) :: Int -\u003e Int -\u003e Bool\n      is antireflexive for \"even Int\"'s\n        +++ OK, passed 100 tests.\n      is transitive for \"even Int\"'s\n        +++ OK, passed 100 tests.\n      is equivalent to (\\a b -\u003e compare a b == GT) for \"even Int\"'s\n        +++ OK, passed 100 tests.\n```\n\n### Free generators and shrinking\n\n``` haskell\ndata MyType = MyType\n  { myRational :: Rational\n  , myBool :: Bool\n  } deriving (Show, Eq, Generic)\n\ninstance Validity MyType -- Implementation is derived via Generic\ninstance GenValid MyType -- Default implementation via Generic\n```\n\n``` haskell\ngenValid :: Gen MyType -- Free generator\nshrinkValid :: MyType -\u003e [MyType] -- Free _valid_ shrinking function\n```\n\n## Cachix cache\n\nThere is a [cachix](https://cachix.org) cache for this project.\n\nTo use it, use `cachix use validity` or add the appropriate details to your nixos configuration.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnorfairking%2Fvalidity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnorfairking%2Fvalidity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnorfairking%2Fvalidity/lists"}