From ed6ba749195256b852b297d4fc7fdb688563a40e Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 00:12:10 -0600 Subject: [PATCH 01/25] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..5e3ed21 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +## [_Unreleased_](https://github.com/freckle/iri-orphans/compare/v0.0.0.0...main) + +## [v0.0.0.0](https://github.com/freckle/iri-orphans/tree/v0.0.0.0) + +First tagged release. From 99a5e4ccd676202bf222542b744041de2ca36caa Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 00:12:16 -0600 Subject: [PATCH 02/25] fourmolu --- fourmolu.yaml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 fourmolu.yaml diff --git a/fourmolu.yaml b/fourmolu.yaml new file mode 100644 index 0000000..811d473 --- /dev/null +++ b/fourmolu.yaml @@ -0,0 +1,37 @@ +indentation: 2 +column-limit: 80 # needs fourmolu >= v0.12 +function-arrows: leading +comma-style: leading # default +import-export-style: leading +import-grouping: # needs fourmolu >= v0.17 + - name: "Preludes" + rules: + - glob: Prelude + - glob: "**.Prelude" + - glob: Import + - glob: "**.Import" + - glob: TestImport + - glob: "**.TestImport" + - glob: "TestImport.**" + - glob: "TestPrelude" + - glob: "**.TestPrelude" + - name: "Everything else" + rules: + - match: all + priority: 100 +indent-wheres: false # default +record-brace-space: true +newlines-between-decls: 1 # default +haddock-style: single-line +let-style: mixed +in-style: left-align +single-constraint-parens: never # needs fourmolu >= v0.12 +sort-constraints: true # needs fourmolu >= v0.17 +sort-derived-classes: true # needs fourmolu >= v0.17 +sort-derived-clauses: true # needs fourmolu >= v0.17 +trailing-section-operators: false # needs fourmolu >= v0.12 +unicode: never # default +respectful: true # default +fixities: + - "infix 4 `stringEqual`" + - "infixl 1 &" From 9addbba1ef4c586fb8bb79eab1f23aae72b8b920 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 00:13:26 -0600 Subject: [PATCH 03/25] renovate --- renovate.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 renovate.json diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..bd84589 --- /dev/null +++ b/renovate.json @@ -0,0 +1,7 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "local>freckle/renovate-config" + ], + "minimumReleaseAge": "0 days" +} From a8f21253258a3a3d737e8c24f49d2bad2395d469 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 00:14:05 -0600 Subject: [PATCH 04/25] codeowners --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..807cb6c --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @freckle/backenders From 68e25fe7da8e5a16e7169d24a89193c6d08edeaa Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 00:14:19 -0600 Subject: [PATCH 05/25] flake --- flake.lock | 571 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 50 +++++ 2 files changed, 621 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c33af0b --- /dev/null +++ b/flake.lock @@ -0,0 +1,571 @@ +{ + "nodes": { + "autodocodec": { + "flake": false, + "locked": { + "lastModified": 1739562847, + "narHash": "sha256-E5EnhdwNCQ4mwMI7rErFqoYLm3zFz1NgfUt6LzpTFPY=", + "owner": "NorfairKing", + "repo": "autodocodec", + "rev": "7439601de128dadf562430f4216cbdb28580ed20", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "repo": "autodocodec", + "type": "github" + } + }, + "fast-myers-diff": { + "flake": false, + "locked": { + "lastModified": 1736948652, + "narHash": "sha256-0iARqmAefoyDk+z1A5D2pyG9JEbdTCkI1zBrTwDviiU=", + "owner": "NorfairKing", + "repo": "fast-myers-diff", + "rev": "4a5c31884b8fc399085bffacd15d6cb5624b3177", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "repo": "fast-myers-diff", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "freckle": { + "inputs": { + "flake-utils": "flake-utils_2", + "haskell-openapi-code-generator": "haskell-openapi-code-generator", + "nix-github-actions": "nix-github-actions", + "nixpkgs-22-11": "nixpkgs-22-11", + "nixpkgs-23-05": "nixpkgs-23-05", + "nixpkgs-23-11": "nixpkgs-23-11", + "nixpkgs-24-05": "nixpkgs-24-05", + "nixpkgs-24-11": "nixpkgs-24-11", + "nixpkgs-haskell-updates": "nixpkgs-haskell-updates", + "nixpkgs-stable": "nixpkgs-stable", + "stack-lint-extra-deps": "stack-lint-extra-deps" + }, + "locked": { + "dir": "main", + "lastModified": 1745046164, + "narHash": "sha256-ffW/nUuo6nE6h0/WuX4KaGWijDRdvHKqzFyYQouvMBQ=", + "owner": "freckle", + "repo": "flakes", + "rev": "9355d795dabfc26f3490efd8f7e153364b311392", + "type": "github" + }, + "original": { + "dir": "main", + "owner": "freckle", + "repo": "flakes", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "freckle", + "haskell-openapi-code-generator", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "haskell-openapi-code-generator": { + "inputs": { + "autodocodec": "autodocodec", + "fast-myers-diff": "fast-myers-diff", + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks", + "safe-coloured-text": "safe-coloured-text", + "sydtest": "sydtest", + "validity": "validity" + }, + "locked": { + "lastModified": 1744629016, + "narHash": "sha256-EYf1ySZ5crofu1M28QphIDr9gEn+5DtIvvo4OVdcm3I=", + "owner": "Haskell-OpenAPI-Code-Generator", + "repo": "Haskell-OpenAPI-Client-Code-Generator", + "rev": "665374f465f214ffa766b5a43c6a6b8b921e4673", + "type": "github" + }, + "original": { + "owner": "Haskell-OpenAPI-Code-Generator", + "repo": "Haskell-OpenAPI-Client-Code-Generator", + "type": "github" + } + }, + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "freckle", + "nixpkgs-stable" + ] + }, + "locked": { + "lastModified": 1737420293, + "narHash": "sha256-F1G5ifvqTpJq7fdkT34e/Jy9VCyzd5XfJ9TO8fHhJWE=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "f4158fa080ef4503c8f4c820967d946c2af31ec9", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1744440957, + "narHash": "sha256-FHlSkNqFmPxPJvy+6fNLaNeWnF1lZSgqVCl/eWaJRc4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "26d499fc9f1d567283d5d56fcf367edd815dba1d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-22-11": { + "locked": { + "lastModified": 1688392541, + "narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-23-05": { + "locked": { + "lastModified": 1704290814, + "narHash": "sha256-LWvKHp7kGxk/GEtlrGYV68qIvPHkU9iToomNFGagixU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "70bdadeb94ffc8806c0570eb5c2695ad29f0e421", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-23-11": { + "locked": { + "lastModified": 1720535198, + "narHash": "sha256-zwVvxrdIzralnSbcpghA92tWu2DV2lwv89xZc8MTrbg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "205fd4226592cc83fd4c0885a3e4c9c400efabb5", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-24-05": { + "locked": { + "lastModified": 1735563628, + "narHash": "sha256-OnSAY7XDSx7CtDoqNh8jwVwh4xNL/2HaJxGjryLWzX8=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b134951a4c9f3c995fd7be05f3243f8ecd65d798", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-24-11": { + "locked": { + "lastModified": 1742751704, + "narHash": "sha256-rBfc+H1dDBUQ2mgVITMGBPI1PGuCznf9rcWX/XIULyE=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "f0946fa5f1fb876a9dc2e1850d9d3a4e3f914092", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-haskell-updates": { + "locked": { + "lastModified": 1744960667, + "narHash": "sha256-GhZOni4cMvmmcQ7gHhv7fq+5FUusD7DKb6CgupKDekA=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c5dbc50d989180a50e0e371e10061d4f739a0511", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "haskell-updates", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-haskell-updates_2": { + "locked": { + "lastModified": 1742210880, + "narHash": "sha256-bFR9Tthdaz1mR/IzdtHgzPuw5nEHn49AWay8iUqFEPM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "1f00f46d8b14f6956005ab80f2e0e9c875d0dace", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "haskell-updates", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1736200483, + "narHash": "sha256-JO+lFN2HsCwSLMUWXHeOad6QUxOuwe9UOAF/iSl1J4I=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "3f0a8ac25fb674611b98089ca3a5dd6480175751", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1730768919, + "narHash": "sha256-8AKquNnnSaJRXZxc5YmF/WfmxiHX6MMZZasRP6RRQkE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a04d33c0c3f1a59a2c1cb0c6e34cd24500e5a1dc", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1742136038, + "narHash": "sha256-DDe16FJk18sadknQKKG/9FbwEro7A57tg9vB5kxZ8kY=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a1185f4064c18a5db37c5c84e5638c78b46e3341", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "pgp-wordlist": { + "flake": false, + "locked": { + "lastModified": 1714149562, + "narHash": "sha256-WCFQgtWqq+gLst4lXkFYlmlW7L8PQOJfChsKMApy3Ng=", + "owner": "quchen", + "repo": "pgp-wordlist", + "rev": "1f0cfd90d62179952cbfd59c3405283a1d364272", + "type": "github" + }, + "original": { + "owner": "quchen", + "repo": "pgp-wordlist", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1742649964, + "narHash": "sha256-DwOTp7nvfi8mRfuL1escHDXabVXFGT1VlPD1JHrtrco=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "dcf5072734cb576d2b0c59b2ac44f5050b5eac82", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "freckle": "freckle", + "stable": "stable" + } + }, + "safe-coloured-text": { + "flake": false, + "locked": { + "lastModified": 1728774106, + "narHash": "sha256-Xfv5izJtsdQ9MFhglkcEjJH4LlZ2m4Wmq+JJgMvnytc=", + "owner": "NorfairKing", + "repo": "safe-coloured-text", + "rev": "9ed65a40b3b2fade447c9d5fcb941d58f6367308", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "repo": "safe-coloured-text", + "type": "github" + } + }, + "stable": { + "locked": { + "lastModified": 1745279238, + "narHash": "sha256-AQ7M9wTa/Pa/kK5pcGTgX/DGqMHyzsyINfN7ktsI7Fo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "9684b53175fc6c09581e94cc85f05ab77464c7e3", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "stack-lint-extra-deps": { + "inputs": { + "nixpkgs": "nixpkgs_3", + "nixpkgs-haskell-updates": "nixpkgs-haskell-updates_2", + "pgp-wordlist": "pgp-wordlist", + "stacklock2nix": "stacklock2nix" + }, + "locked": { + "lastModified": 1744218263, + "narHash": "sha256-DZg4hwzEe63oiaFRxyH2ek08cOVDrrFXpU2HzbtJE4I=", + "owner": "freckle", + "repo": "stack-lint-extra-deps", + "rev": "3ccabc07f47e244ee42d9841774739849d69cd78", + "type": "github" + }, + "original": { + "owner": "freckle", + "repo": "stack-lint-extra-deps", + "type": "github" + } + }, + "stacklock2nix": { + "locked": { + "lastModified": 1741332755, + "narHash": "sha256-ZQlzcx4f2cx4CQBQzMvEwJEAWJrfZEdZrGY7Iu5L9MA=", + "owner": "cdepillabout", + "repo": "stacklock2nix", + "rev": "47dd3fb2827fc0868142ab41a7daeaec0a6ddda1", + "type": "github" + }, + "original": { + "owner": "cdepillabout", + "repo": "stacklock2nix", + "type": "github" + } + }, + "sydtest": { + "flake": false, + "locked": { + "lastModified": 1742493430, + "narHash": "sha256-qATPlVpxHpnUe8n+EQlJyol/lh6RKoimVftHnCzUqFc=", + "owner": "NorfairKing", + "repo": "sydtest", + "rev": "0aad7d9c41a53f5d46694c87dcacc51f6c6063d5", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "repo": "sydtest", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "validity": { + "flake": false, + "locked": { + "lastModified": 1728772377, + "narHash": "sha256-5hHY8A8lO87G9TQLjwqCFzXmFMeXE71jeanuqHTS3T8=", + "owner": "NorfairKing", + "repo": "validity", + "rev": "512aea6e0a112f5df09cc0b08f7fceffb122abc6", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "repo": "validity", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..2040717 --- /dev/null +++ b/flake.nix @@ -0,0 +1,50 @@ +{ + inputs = { + stable.url = "github:nixos/nixpkgs/nixos-24.11"; + freckle.url = "github:freckle/flakes?dir=main"; + flake-utils.url = "github:numtide/flake-utils"; + }; + outputs = + inputs: + inputs.flake-utils.lib.eachDefaultSystem ( + system: + let + nixpkgsArgs = { + inherit system; + config = { }; + }; + + nixpkgs = { + stable = import inputs.stable nixpkgsArgs; + }; + freckle = inputs.freckle.packages.${system}; + freckleLib = inputs.freckle.lib.${system}; + + in + rec { + packages = { + fourmolu = freckle.fourmolu-0-17-x; + + ghc = freckleLib.haskellBundle { + ghcVersion = "ghc-9-8-4"; + enableHLS = true; + }; + }; + + devShells.default = nixpkgs.stable.mkShell { + buildInputs = with (nixpkgs.stable); [ + zlib + ]; + + nativeBuildInputs = with (packages); [ + fourmolu + ghc + ]; + + shellHook = '' + export STACK_YAML=stack.yaml + ''; + }; + } + ); +} From ff02e6adbd736aa4dd92e3ad58bd9be587a32ad4 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 00:20:40 -0600 Subject: [PATCH 06/25] gitignore --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..271d433 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*.hie +.hiedb +.stack-work +stack*.yaml.lock +.envrc +.direnv From 40583dc9b16f76aaa57bdc86e4d8129ddc64dc82 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 00:20:49 -0600 Subject: [PATCH 07/25] stack files --- stack-lts22.yaml | 1 + stack-lts23.yaml | 1 + stack-nightly.yaml | 1 + stack.yaml | 1 + 4 files changed, 4 insertions(+) create mode 100644 stack-lts22.yaml create mode 100644 stack-lts23.yaml create mode 100644 stack-nightly.yaml create mode 120000 stack.yaml diff --git a/stack-lts22.yaml b/stack-lts22.yaml new file mode 100644 index 0000000..c757eef --- /dev/null +++ b/stack-lts22.yaml @@ -0,0 +1 @@ +resolver: lts-22.43 diff --git a/stack-lts23.yaml b/stack-lts23.yaml new file mode 100644 index 0000000..aac0e04 --- /dev/null +++ b/stack-lts23.yaml @@ -0,0 +1 @@ +resolver: lts-23.19 diff --git a/stack-nightly.yaml b/stack-nightly.yaml new file mode 100644 index 0000000..128cd50 --- /dev/null +++ b/stack-nightly.yaml @@ -0,0 +1 @@ +resolver: nightly-2025-04-24 diff --git a/stack.yaml b/stack.yaml new file mode 120000 index 0000000..d7de56b --- /dev/null +++ b/stack.yaml @@ -0,0 +1 @@ +stack-lts23.yaml \ No newline at end of file From ce960539d5e12030375015f2f43448aa48b2182a Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 00:21:11 -0600 Subject: [PATCH 08/25] github workflows --- .github/workflows/add-asana-comment.yml | 16 +++++++++ .github/workflows/ci.yml | 45 +++++++++++++++++++++++++ .github/workflows/release.yml | 20 +++++++++++ .github/workflows/restyled.yml | 18 ++++++++++ 4 files changed, 99 insertions(+) create mode 100644 .github/workflows/add-asana-comment.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/restyled.yml diff --git a/.github/workflows/add-asana-comment.yml b/.github/workflows/add-asana-comment.yml new file mode 100644 index 0000000..aaa3f6d --- /dev/null +++ b/.github/workflows/add-asana-comment.yml @@ -0,0 +1,16 @@ +name: Asana + +on: + pull_request: + types: [opened] + +jobs: + link-asana-task: + if: ${{ github.actor != 'dependabot[bot]' }} + runs-on: ubuntu-latest + steps: + - uses: Asana/create-app-attachment-github-action@v1.3 + id: postAttachment + with: + asana-secret: ${{ secrets.ASANA_API_ACCESS_KEY }} + - run: echo "Status is ${{ steps.postAttachment.outputs.status }}" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..477a784 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +name: CI + +on: + pull_request: + push: + branches: main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + generate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - id: generate + uses: freckle/stack-action/generate-matrix@v5 + outputs: + stack-yamls: ${{ steps.generate.outputs.stack-yamls }} + + test: + needs: generate + runs-on: ubuntu-latest + + strategy: + matrix: + stack-yaml: ${{ fromJSON(needs.generate.outputs.stack-yamls) }} + fail-fast: false + + steps: + - uses: actions/checkout@v4 + - id: stack + uses: freckle/stack-action@v5 + env: + STACK_YAML: ${{ matrix.stack-yaml }} + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: haskell-actions/hlint-setup@v2 + - uses: haskell-actions/hlint-run@v2 + with: + fail-on: warning diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2656be6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,20 @@ +name: Release + +on: + push: + branches: main + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - id: tag + uses: freckle/haskell-tag-action@v1 + + - if: steps.tag.outputs.tag + run: stack upload --pvp-bounds lower . + env: + HACKAGE_KEY: ${{ secrets.HACKAGE_UPLOAD_API_KEY }} + STACK_YAML: stack-lts22.yaml diff --git a/.github/workflows/restyled.yml b/.github/workflows/restyled.yml new file mode 100644 index 0000000..b54bdc6 --- /dev/null +++ b/.github/workflows/restyled.yml @@ -0,0 +1,18 @@ +name: Restyled + +on: + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + restyled: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: restyled-io/actions/setup@v4 + - uses: restyled-io/actions/run@v4 + with: + suggestions: true From c1aad31b6bf08bb8c40ca1fae20f4787c1299328 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 00:25:33 -0600 Subject: [PATCH 09/25] package boilerplate --- README.md | 1 + iri-orphans.cabal | 73 ++++++++++++++++++++++++++++++++++++++++++++ package.yaml | 76 ++++++++++++++++++++++++++++++++++++++++++++++ src/Iri/Orphans.hs | 1 + 4 files changed, 151 insertions(+) create mode 100644 iri-orphans.cabal create mode 100644 package.yaml create mode 100644 src/Iri/Orphans.hs diff --git a/README.md b/README.md index 47c9bc8..9743fc6 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # iri-orphans + Haskell package defining orphan instances for types defined in the `iri` package diff --git a/iri-orphans.cabal b/iri-orphans.cabal new file mode 100644 index 0000000..2c70d8f --- /dev/null +++ b/iri-orphans.cabal @@ -0,0 +1,73 @@ +cabal-version: 1.18 + +-- This file has been generated from package.yaml by hpack version 0.37.0. +-- +-- see: https://github.com/sol/hpack + +name: iri-orphans +version: 0.0.0.0 +synopsis: Orphan instances for iri +description: Orphan instances for types defined in the `iri` package. +category: Utils +homepage: https://github.com/freckle/iri-orphans#readme +bug-reports: https://github.com/freckle/iri-orphans/issues +maintainer: Freckle Education +license: MIT +license-file: LICENSE +build-type: Simple +extra-source-files: + package.yaml +extra-doc-files: + README.md + CHANGELOG.md + +source-repository head + type: git + location: https://github.com/freckle/iri-orphans + +library + exposed-modules: + Iri.Orphans + other-modules: + Paths_iri_orphans + hs-source-dirs: + src + default-extensions: + ApplicativeDo + BangPatterns + BlockArguments + DataKinds + DeriveAnyClass + DeriveFoldable + DeriveFunctor + DeriveGeneric + DeriveLift + DeriveTraversable + DerivingStrategies + FlexibleContexts + FlexibleInstances + GADTs + GeneralizedNewtypeDeriving + LambdaCase + MultiParamTypeClasses + NoImplicitPrelude + NoMonomorphismRestriction + OverloadedStrings + RankNTypes + RecordWildCards + ScopedTypeVariables + StandaloneDeriving + TypeApplications + TypeFamilies + ghc-options: -Weverything -Wno-all-missed-specialisations -Wno-missed-specialisations -Wno-missing-exported-signatures -Wno-missing-import-lists -Wno-missing-local-signatures -Wno-monomorphism-restriction -Wno-safe -Wno-unsafe + build-depends: + base <5 + default-language: Haskell2010 + if impl(ghc >= 9.8) + ghc-options: -Wno-missing-role-annotations -Wno-missing-poly-kind-signatures + if impl(ghc >= 9.2) + ghc-options: -Wno-missing-kind-signatures + if impl(ghc >= 8.10) + ghc-options: -Wno-missing-safe-haskell-mode -Wno-prepositive-qualified-module + if impl(ghc >= 8.8) + ghc-options: -fwrite-ide-info diff --git a/package.yaml b/package.yaml new file mode 100644 index 0000000..d40a87b --- /dev/null +++ b/package.yaml @@ -0,0 +1,76 @@ +name: iri-orphans +version: 0.0.0.0 +maintainer: Freckle Education +category: Utils +github: freckle/iri-orphans +synopsis: Orphan instances for iri +description: | + Orphan instances for types defined in the `iri` package. + +extra-doc-files: + - README.md + - CHANGELOG.md + +extra-source-files: + - package.yaml + +ghc-options: + - -Weverything + - -Wno-all-missed-specialisations + - -Wno-missed-specialisations + - -Wno-missing-exported-signatures # re-enables missing-signatures + - -Wno-missing-import-lists + - -Wno-missing-local-signatures + - -Wno-monomorphism-restriction + - -Wno-safe + - -Wno-unsafe + +when: + - condition: "impl(ghc >= 9.8)" + ghc-options: + - -Wno-missing-role-annotations + - -Wno-missing-poly-kind-signatures + - condition: "impl(ghc >= 9.2)" + ghc-options: + - -Wno-missing-kind-signatures + - condition: "impl(ghc >= 8.10)" + ghc-options: + - -Wno-missing-safe-haskell-mode + - -Wno-prepositive-qualified-module + - condition: "impl(ghc >= 8.8)" + ghc-options: + - -fwrite-ide-info + +dependencies: + - base < 5 + +default-extensions: + - ApplicativeDo + - BangPatterns + - BlockArguments + - DataKinds + - DeriveAnyClass + - DeriveFoldable + - DeriveFunctor + - DeriveGeneric + - DeriveLift + - DeriveTraversable + - DerivingStrategies + - FlexibleContexts + - FlexibleInstances + - GADTs + - GeneralizedNewtypeDeriving + - LambdaCase + - MultiParamTypeClasses + - NoImplicitPrelude + - NoMonomorphismRestriction + - OverloadedStrings + - RankNTypes + - RecordWildCards + - ScopedTypeVariables + - StandaloneDeriving + - TypeApplications + - TypeFamilies + +library: + source-dirs: src diff --git a/src/Iri/Orphans.hs b/src/Iri/Orphans.hs new file mode 100644 index 0000000..a894451 --- /dev/null +++ b/src/Iri/Orphans.hs @@ -0,0 +1 @@ +module Iri.Orphans () where From 9301c12223c1de2263d9d0b2edfa93372fc19bf7 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 01:44:26 -0600 Subject: [PATCH 10/25] code --- iri-orphans.cabal | 91 +++++++++++++++++-- package.yaml | 37 ++++++-- src/Iri/Orphans.hs | 8 ++ src/Iri/Orphans/Aeson.hs | 4 + src/Iri/Orphans/Aeson/FromJSON.hs | 10 ++ src/Iri/Orphans/Aeson/ToJSON.hs | 10 ++ src/Iri/Orphans/Autodocodec.hs | 3 + src/Iri/Orphans/Autodocodec/HasCodec.hs | 20 ++++ src/Iri/Orphans/DebugPrint.hs | 3 + .../Orphans/DebugPrint/ToDebugPrintValue.hs | 14 +++ src/Iri/Orphans/OpenApi.hs | 3 + src/Iri/Orphans/OpenApi/ToSchema.hs | 15 +++ src/Iri/Orphans/Persistent.hs | 4 + src/Iri/Orphans/Persistent/PersistField.hs | 16 ++++ src/Iri/Orphans/Persistent/PersistFieldSql.hs | 14 +++ src/Iri/Orphans/QuickCheck.hs | 3 + src/Iri/Orphans/QuickCheck/Arbitrary.hs | 44 +++++++++ src/Iri/Orphans/Serialise.hs | 3 + src/Iri/Orphans/Serialise/Serialise.hs | 23 +++++ stack-lts22.yaml | 6 ++ stack-lts23.yaml | 6 ++ stack-nightly.yaml | 6 ++ test/Iri/Orphans/QuickCheck/ArbitrarySpec.hs | 31 +++++++ test/Spec.hs | 1 + test/SpecHook.hs | 11 +++ 25 files changed, 372 insertions(+), 14 deletions(-) create mode 100644 src/Iri/Orphans/Aeson.hs create mode 100644 src/Iri/Orphans/Aeson/FromJSON.hs create mode 100644 src/Iri/Orphans/Aeson/ToJSON.hs create mode 100644 src/Iri/Orphans/Autodocodec.hs create mode 100644 src/Iri/Orphans/Autodocodec/HasCodec.hs create mode 100644 src/Iri/Orphans/DebugPrint.hs create mode 100644 src/Iri/Orphans/DebugPrint/ToDebugPrintValue.hs create mode 100644 src/Iri/Orphans/OpenApi.hs create mode 100644 src/Iri/Orphans/OpenApi/ToSchema.hs create mode 100644 src/Iri/Orphans/Persistent.hs create mode 100644 src/Iri/Orphans/Persistent/PersistField.hs create mode 100644 src/Iri/Orphans/Persistent/PersistFieldSql.hs create mode 100644 src/Iri/Orphans/QuickCheck.hs create mode 100644 src/Iri/Orphans/QuickCheck/Arbitrary.hs create mode 100644 src/Iri/Orphans/Serialise.hs create mode 100644 src/Iri/Orphans/Serialise/Serialise.hs create mode 100644 test/Iri/Orphans/QuickCheck/ArbitrarySpec.hs create mode 100644 test/Spec.hs create mode 100644 test/SpecHook.hs diff --git a/iri-orphans.cabal b/iri-orphans.cabal index 2c70d8f..78ddaae 100644 --- a/iri-orphans.cabal +++ b/iri-orphans.cabal @@ -28,6 +28,22 @@ source-repository head library exposed-modules: Iri.Orphans + Iri.Orphans.Aeson + Iri.Orphans.Aeson.FromJSON + Iri.Orphans.Aeson.ToJSON + Iri.Orphans.Autodocodec + Iri.Orphans.Autodocodec.HasCodec + Iri.Orphans.DebugPrint + Iri.Orphans.DebugPrint.ToDebugPrintValue + Iri.Orphans.OpenApi + Iri.Orphans.OpenApi.ToSchema + Iri.Orphans.Persistent + Iri.Orphans.Persistent.PersistField + Iri.Orphans.Persistent.PersistFieldSql + Iri.Orphans.QuickCheck + Iri.Orphans.QuickCheck.Arbitrary + Iri.Orphans.Serialise + Iri.Orphans.Serialise.Serialise other-modules: Paths_iri_orphans hs-source-dirs: @@ -37,13 +53,8 @@ library BangPatterns BlockArguments DataKinds - DeriveAnyClass - DeriveFoldable - DeriveFunctor - DeriveGeneric - DeriveLift - DeriveTraversable DerivingStrategies + DerivingVia FlexibleContexts FlexibleInstances GADTs @@ -61,8 +72,72 @@ library TypeFamilies ghc-options: -Weverything -Wno-all-missed-specialisations -Wno-missed-specialisations -Wno-missing-exported-signatures -Wno-missing-import-lists -Wno-missing-local-signatures -Wno-monomorphism-restriction -Wno-safe -Wno-unsafe build-depends: - base <5 - default-language: Haskell2010 + QuickCheck + , aeson + , autodocodec + , base <5 + , bytestring + , debug-print + , generic-arbitrary + , ip + , iri + , lens + , openapi3 + , persistent + , serialise + , text + , vector + , wide-word + default-language: GHC2021 + if impl(ghc >= 9.8) + ghc-options: -Wno-missing-role-annotations -Wno-missing-poly-kind-signatures + if impl(ghc >= 9.2) + ghc-options: -Wno-missing-kind-signatures + if impl(ghc >= 8.10) + ghc-options: -Wno-missing-safe-haskell-mode -Wno-prepositive-qualified-module + if impl(ghc >= 8.8) + ghc-options: -fwrite-ide-info + +test-suite spec + type: exitcode-stdio-1.0 + main-is: Spec.hs + other-modules: + Iri.Orphans.QuickCheck.ArbitrarySpec + SpecHook + Paths_iri_orphans + hs-source-dirs: + test + default-extensions: + ApplicativeDo + BangPatterns + BlockArguments + DataKinds + DerivingStrategies + DerivingVia + FlexibleContexts + FlexibleInstances + GADTs + GeneralizedNewtypeDeriving + LambdaCase + MultiParamTypeClasses + NoImplicitPrelude + NoMonomorphismRestriction + OverloadedStrings + RankNTypes + RecordWildCards + ScopedTypeVariables + StandaloneDeriving + TypeApplications + TypeFamilies + ghc-options: -Weverything -Wno-all-missed-specialisations -Wno-missed-specialisations -Wno-missing-exported-signatures -Wno-missing-import-lists -Wno-missing-local-signatures -Wno-monomorphism-restriction -Wno-safe -Wno-unsafe -threaded -rtsopts "-with-rtsopts=-N" + build-depends: + QuickCheck + , base <5 + , hspec + , hspec-junit-formatter + , iri + , iri-orphans + default-language: GHC2021 if impl(ghc >= 9.8) ghc-options: -Wno-missing-role-annotations -Wno-missing-poly-kind-signatures if impl(ghc >= 9.2) diff --git a/package.yaml b/package.yaml index d40a87b..827e1cb 100644 --- a/package.yaml +++ b/package.yaml @@ -44,18 +44,15 @@ when: dependencies: - base < 5 +language: GHC2021 + default-extensions: - ApplicativeDo - BangPatterns - BlockArguments - DataKinds - - DeriveAnyClass - - DeriveFoldable - - DeriveFunctor - - DeriveGeneric - - DeriveLift - - DeriveTraversable - DerivingStrategies + - DerivingVia - FlexibleContexts - FlexibleInstances - GADTs @@ -74,3 +71,31 @@ default-extensions: library: source-dirs: src + dependencies: + - aeson + - autodocodec + - bytestring + - debug-print + - generic-arbitrary + - ip + - iri + - lens + - openapi3 + - persistent + - QuickCheck + - serialise + - text + - vector + - wide-word + +tests: + spec: + main: Spec.hs + source-dirs: test + ghc-options: -threaded -rtsopts "-with-rtsopts=-N" + dependencies: + - hspec + - hspec-junit-formatter + - iri + - iri-orphans + - QuickCheck diff --git a/src/Iri/Orphans.hs b/src/Iri/Orphans.hs index a894451..0ea66bf 100644 --- a/src/Iri/Orphans.hs +++ b/src/Iri/Orphans.hs @@ -1 +1,9 @@ module Iri.Orphans () where + +import Iri.Orphans.Aeson () +import Iri.Orphans.Autodocodec () +import Iri.Orphans.DebugPrint () +import Iri.Orphans.OpenApi () +import Iri.Orphans.Persistent () +import Iri.Orphans.QuickCheck () +import Iri.Orphans.Serialise () diff --git a/src/Iri/Orphans/Aeson.hs b/src/Iri/Orphans/Aeson.hs new file mode 100644 index 0000000..997f573 --- /dev/null +++ b/src/Iri/Orphans/Aeson.hs @@ -0,0 +1,4 @@ +module Iri.Orphans.Aeson () where + +import Iri.Orphans.Aeson.FromJSON () +import Iri.Orphans.Aeson.ToJSON () diff --git a/src/Iri/Orphans/Aeson/FromJSON.hs b/src/Iri/Orphans/Aeson/FromJSON.hs new file mode 100644 index 0000000..2f8f2db --- /dev/null +++ b/src/Iri/Orphans/Aeson/FromJSON.hs @@ -0,0 +1,10 @@ +{-# options_ghc -Wno-orphans #-} + +module Iri.Orphans.Aeson.FromJSON () where + +import Autodocodec (Autodocodec (..)) +import Data.Aeson (FromJSON) +import Iri.Data (HttpIri) +import Iri.Orphans.Autodocodec.HasCodec() + +deriving via Autodocodec HttpIri instance FromJSON HttpIri diff --git a/src/Iri/Orphans/Aeson/ToJSON.hs b/src/Iri/Orphans/Aeson/ToJSON.hs new file mode 100644 index 0000000..de7ec26 --- /dev/null +++ b/src/Iri/Orphans/Aeson/ToJSON.hs @@ -0,0 +1,10 @@ +{-# OPTIONS_GHC -Wno-orphans #-} + +module Iri.Orphans.Aeson.ToJSON () where + +import Autodocodec (Autodocodec (..)) +import Data.Aeson (ToJSON) +import Iri.Data (HttpIri) +import Iri.Orphans.Autodocodec.HasCodec () + +deriving via Autodocodec HttpIri instance ToJSON HttpIri diff --git a/src/Iri/Orphans/Autodocodec.hs b/src/Iri/Orphans/Autodocodec.hs new file mode 100644 index 0000000..02572ce --- /dev/null +++ b/src/Iri/Orphans/Autodocodec.hs @@ -0,0 +1,3 @@ +module Iri.Orphans.Autodocodec () where + +import Iri.Orphans.Autodocodec.HasCodec () diff --git a/src/Iri/Orphans/Autodocodec/HasCodec.hs b/src/Iri/Orphans/Autodocodec/HasCodec.hs new file mode 100644 index 0000000..e2b3fff --- /dev/null +++ b/src/Iri/Orphans/Autodocodec/HasCodec.hs @@ -0,0 +1,20 @@ +{-# OPTIONS_GHC -Wno-orphans #-} + +module Iri.Orphans.Autodocodec.HasCodec () where + +import Prelude + +import Autodocodec (HasCodec (codec), bimapCodec) +import Data.Bifunctor (first) +import Data.Text (Text) +import Data.Text qualified as T +import Iri.Data (HttpIri) +import Iri.Parsing.Text qualified +import Iri.Rendering.Text qualified + +instance HasCodec HttpIri where + codec = + bimapCodec + (first T.unpack . Iri.Parsing.Text.httpIri) + Iri.Rendering.Text.httpIri + (codec @Text) diff --git a/src/Iri/Orphans/DebugPrint.hs b/src/Iri/Orphans/DebugPrint.hs new file mode 100644 index 0000000..28d5f9b --- /dev/null +++ b/src/Iri/Orphans/DebugPrint.hs @@ -0,0 +1,3 @@ +module Iri.Orphans.DebugPrint () where + +import Iri.Orphans.DebugPrint.ToDebugPrintValue () diff --git a/src/Iri/Orphans/DebugPrint/ToDebugPrintValue.hs b/src/Iri/Orphans/DebugPrint/ToDebugPrintValue.hs new file mode 100644 index 0000000..2b24743 --- /dev/null +++ b/src/Iri/Orphans/DebugPrint/ToDebugPrintValue.hs @@ -0,0 +1,14 @@ +{-# OPTIONS_GHC -Wno-orphans #-} + +module Iri.Orphans.DebugPrint.ToDebugPrintValue () where + +import Prelude + +import Data.Text (Text) +import DebugPrint (ToDebugPrintValue (..)) +import Iri.Data (HttpIri) +import Iri.Rendering.Text qualified + +instance ToDebugPrintValue HttpIri where + toDebugPrintValue = + toDebugPrintValue @Text . Iri.Rendering.Text.httpIri diff --git a/src/Iri/Orphans/OpenApi.hs b/src/Iri/Orphans/OpenApi.hs new file mode 100644 index 0000000..332e454 --- /dev/null +++ b/src/Iri/Orphans/OpenApi.hs @@ -0,0 +1,3 @@ +module Iri.Orphans.OpenApi () where + +import Iri.Orphans.OpenApi.ToSchema () diff --git a/src/Iri/Orphans/OpenApi/ToSchema.hs b/src/Iri/Orphans/OpenApi/ToSchema.hs new file mode 100644 index 0000000..c3069b6 --- /dev/null +++ b/src/Iri/Orphans/OpenApi/ToSchema.hs @@ -0,0 +1,15 @@ +{-# OPTIONS_GHC -Wno-orphans #-} + +module Iri.Orphans.OpenApi.ToSchema () where + +import Prelude + +import Control.Lens ((&), (?~)) +import Data.OpenApi +import Iri.Data (HttpIri) + +instance ToSchema HttpIri where + declareNamedSchema _ = + pure + $ NamedSchema (Just "HttpIri") + $ mempty & type_ ?~ OpenApiString diff --git a/src/Iri/Orphans/Persistent.hs b/src/Iri/Orphans/Persistent.hs new file mode 100644 index 0000000..6dca94e --- /dev/null +++ b/src/Iri/Orphans/Persistent.hs @@ -0,0 +1,4 @@ +module Iri.Orphans.Persistent () where + +import Iri.Orphans.Persistent.PersistField () +import Iri.Orphans.Persistent.PersistFieldSql () diff --git a/src/Iri/Orphans/Persistent/PersistField.hs b/src/Iri/Orphans/Persistent/PersistField.hs new file mode 100644 index 0000000..26d0432 --- /dev/null +++ b/src/Iri/Orphans/Persistent/PersistField.hs @@ -0,0 +1,16 @@ +{-# OPTIONS_GHC -Wno-orphans #-} + +module Iri.Orphans.Persistent.PersistField () where + +import Prelude + +import Control.Monad ((<=<)) +import Data.Text (Text) +import Database.Persist +import Iri.Data (HttpIri) +import Iri.Parsing.Text qualified +import Iri.Rendering.Text qualified + +instance PersistField HttpIri where + toPersistValue = toPersistValue @Text . Iri.Rendering.Text.httpIri + fromPersistValue = Iri.Parsing.Text.httpIri <=< fromPersistValue @Text diff --git a/src/Iri/Orphans/Persistent/PersistFieldSql.hs b/src/Iri/Orphans/Persistent/PersistFieldSql.hs new file mode 100644 index 0000000..1a36cac --- /dev/null +++ b/src/Iri/Orphans/Persistent/PersistFieldSql.hs @@ -0,0 +1,14 @@ +{-# OPTIONS_GHC -Wno-orphans #-} + +module Iri.Orphans.Persistent.PersistFieldSql () where + +import Prelude + +import Data.Proxy +import Data.Text (Text) +import Database.Persist.Sql +import Iri.Data (HttpIri) +import Iri.Orphans.Persistent.PersistField () + +instance PersistFieldSql HttpIri where + sqlType _ = sqlType $ Proxy @Text diff --git a/src/Iri/Orphans/QuickCheck.hs b/src/Iri/Orphans/QuickCheck.hs new file mode 100644 index 0000000..5ab3d94 --- /dev/null +++ b/src/Iri/Orphans/QuickCheck.hs @@ -0,0 +1,3 @@ +module Iri.Orphans.QuickCheck () where + +import Iri.Orphans.QuickCheck.Arbitrary () diff --git a/src/Iri/Orphans/QuickCheck/Arbitrary.hs b/src/Iri/Orphans/QuickCheck/Arbitrary.hs new file mode 100644 index 0000000..19016bb --- /dev/null +++ b/src/Iri/Orphans/QuickCheck/Arbitrary.hs @@ -0,0 +1,44 @@ +{-# OPTIONS_GHC -Wno-orphans #-} + +module Iri.Orphans.QuickCheck.Arbitrary () where + +import Prelude + +import Data.ByteString qualified as BS +import Data.Text qualified as T +import Data.Vector qualified as V +import Data.WideWord.Word128 +import Iri.Data +import Net.IPv4 +import Net.IPv6 +import Test.QuickCheck.Arbitrary.Generic +import Test.QuickCheck.Gen (choose, listOf, listOf1) + +deriving via GenericArbitrary HttpIri instance Arbitrary HttpIri +deriving via GenericArbitrary Port instance Arbitrary Port +deriving via GenericArbitrary Word128 instance Arbitrary Word128 + +deriving newtype instance Arbitrary IPv4 +deriving newtype instance Arbitrary IPv6 +deriving newtype instance Arbitrary Security + +instance Arbitrary DomainLabel where + arbitrary = DomainLabel . T.pack <$> listOf1 (choose ('a', 'z')) + +instance Arbitrary Fragment where + arbitrary = Fragment . BS.pack <$> listOf (choose (97, 122)) + +instance Arbitrary Host where + arbitrary = NamedHost <$> arbitrary + +instance Arbitrary Path where + arbitrary = Path . V.fromList <$> listOf arbitrary + +instance Arbitrary PathSegment where + arbitrary = PathSegment . BS.pack <$> listOf1 (choose (97, 122)) + +instance Arbitrary Query where + arbitrary = Query . BS.pack <$> listOf (choose (97, 122)) + +instance Arbitrary RegName where + arbitrary = RegName . V.fromList <$> listOf1 arbitrary diff --git a/src/Iri/Orphans/Serialise.hs b/src/Iri/Orphans/Serialise.hs new file mode 100644 index 0000000..f3fe1f3 --- /dev/null +++ b/src/Iri/Orphans/Serialise.hs @@ -0,0 +1,3 @@ +module Iri.Orphans.Serialise () where + +import Iri.Orphans.Serialise.Serialise () diff --git a/src/Iri/Orphans/Serialise/Serialise.hs b/src/Iri/Orphans/Serialise/Serialise.hs new file mode 100644 index 0000000..5d83abf --- /dev/null +++ b/src/Iri/Orphans/Serialise/Serialise.hs @@ -0,0 +1,23 @@ +{-# OPTIONS_GHC -Wno-orphans #-} + +module Iri.Orphans.Serialise.Serialise () where + +import Codec.Serialise (Serialise) +import Data.WideWord.Word128 (Word128) +import Iri.Data +import Net.IPv4 (IPv4) +import Net.IPv6 (IPv6) + +instance Serialise DomainLabel +instance Serialise Fragment +instance Serialise Host +instance Serialise HttpIri +instance Serialise IPv4 +instance Serialise IPv6 +instance Serialise Path +instance Serialise PathSegment +instance Serialise Port +instance Serialise Query +instance Serialise RegName +instance Serialise Security +instance Serialise Word128 diff --git a/stack-lts22.yaml b/stack-lts22.yaml index c757eef..88170c3 100644 --- a/stack-lts22.yaml +++ b/stack-lts22.yaml @@ -1 +1,7 @@ resolver: lts-22.43 + +extra-deps: + - debug-print-0.2.0.0 + - iri-0.5.1.1 + - text-builder-1.0.0.3 + - text-builder-core-0.1.1.1 diff --git a/stack-lts23.yaml b/stack-lts23.yaml index aac0e04..e7ab147 100644 --- a/stack-lts23.yaml +++ b/stack-lts23.yaml @@ -1 +1,7 @@ resolver: lts-23.19 + +extra-deps: + - debug-print-0.2.0.0 + - iri-0.5.1.1 + - text-builder-1.0.0.3 + - text-builder-core-0.1.1.1 diff --git a/stack-nightly.yaml b/stack-nightly.yaml index 128cd50..ad86e7d 100644 --- a/stack-nightly.yaml +++ b/stack-nightly.yaml @@ -1 +1,7 @@ resolver: nightly-2025-04-24 + +extra-deps: + - debug-print-0.2.0.0 + - iri-0.5.1.1 + - text-builder-1.0.0.3 + - text-builder-core-0.1.1.1 diff --git a/test/Iri/Orphans/QuickCheck/ArbitrarySpec.hs b/test/Iri/Orphans/QuickCheck/ArbitrarySpec.hs new file mode 100644 index 0000000..3f427a3 --- /dev/null +++ b/test/Iri/Orphans/QuickCheck/ArbitrarySpec.hs @@ -0,0 +1,31 @@ +module Iri.Orphans.QuickCheck.ArbitrarySpec ( + spec + ) where + +import Prelude + +import Test.Hspec + +import Data.List (intercalate) +import Iri.Data (HttpIri (..)) +import Iri.Parsing.Text qualified +import Iri.Rendering.Text qualified +import Iri.Orphans.QuickCheck() +import Test.QuickCheck (counterexample, property) + +spec :: Spec +spec = + it "generates only parseable values" $ property $ \x -> + counterexample + ( let HttpIri security host port path query fragment = x + in intercalate + ", " + [ show security + , show host + , show port + , show path + , show query + , show fragment + ] + ) + $ Iri.Parsing.Text.httpIri (Iri.Rendering.Text.httpIri x) == Right x diff --git a/test/Spec.hs b/test/Spec.hs new file mode 100644 index 0000000..8044961 --- /dev/null +++ b/test/Spec.hs @@ -0,0 +1 @@ +{-# OPTIONS_GHC -F -pgmF hspec-discover -Wno-missing-export-lists #-} diff --git a/test/SpecHook.hs b/test/SpecHook.hs new file mode 100644 index 0000000..e064a69 --- /dev/null +++ b/test/SpecHook.hs @@ -0,0 +1,11 @@ +module SpecHook + ( hook + ) where + +import Prelude + +import Test.Hspec +import Test.Hspec.JUnit.Formatter.Env as Formatter + +hook :: Spec -> Spec +hook = Formatter.whenEnabled Formatter.add . parallel From b800bc58f4ef58abcf1b19ff8ff6a9a5be43cf2d Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 01:46:55 -0600 Subject: [PATCH 11/25] lts21 --- .github/workflows/release.yml | 2 +- stack-lts21.yaml | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 stack-lts21.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2656be6..d0a6afa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,4 +17,4 @@ jobs: run: stack upload --pvp-bounds lower . env: HACKAGE_KEY: ${{ secrets.HACKAGE_UPLOAD_API_KEY }} - STACK_YAML: stack-lts22.yaml + STACK_YAML: stack-lts21.yaml diff --git a/stack-lts21.yaml b/stack-lts21.yaml new file mode 100644 index 0000000..dbce65d --- /dev/null +++ b/stack-lts21.yaml @@ -0,0 +1,7 @@ +resolver: lts-21.25 + +extra-deps: + - debug-print-0.2.0.0 + - iri-0.5.1.1 + - text-builder-1.0.0.3 + - text-builder-core-0.1.1.1 From e561eeccdc19469c344462524b4c7cbf9db3ff4a Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 01:50:47 -0600 Subject: [PATCH 12/25] restyled config --- .restyled.yaml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .restyled.yaml diff --git a/.restyled.yaml b/.restyled.yaml new file mode 100644 index 0000000..be7a0c0 --- /dev/null +++ b/.restyled.yaml @@ -0,0 +1,4 @@ +restylers: + - fourmolu + - "!stylish-haskell" + - "*" From b3240555b3e614342eb844e6a8b8f2606b6b0738 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 10:20:19 -0600 Subject: [PATCH 13/25] Update test/Iri/Orphans/QuickCheck/ArbitrarySpec.hs Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- test/Iri/Orphans/QuickCheck/ArbitrarySpec.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Iri/Orphans/QuickCheck/ArbitrarySpec.hs b/test/Iri/Orphans/QuickCheck/ArbitrarySpec.hs index 3f427a3..cffbfaf 100644 --- a/test/Iri/Orphans/QuickCheck/ArbitrarySpec.hs +++ b/test/Iri/Orphans/QuickCheck/ArbitrarySpec.hs @@ -1,6 +1,6 @@ -module Iri.Orphans.QuickCheck.ArbitrarySpec ( - spec - ) where +module Iri.Orphans.QuickCheck.ArbitrarySpec + ( spec + ) where import Prelude From cb8d34d5386891c61dd89ba759f3cebfb5b24cae Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 10:25:41 -0600 Subject: [PATCH 14/25] restyle --- src/Iri/Orphans/Aeson/FromJSON.hs | 4 ++-- test/Iri/Orphans/QuickCheck/ArbitrarySpec.hs | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Iri/Orphans/Aeson/FromJSON.hs b/src/Iri/Orphans/Aeson/FromJSON.hs index 2f8f2db..0b1ba1d 100644 --- a/src/Iri/Orphans/Aeson/FromJSON.hs +++ b/src/Iri/Orphans/Aeson/FromJSON.hs @@ -1,10 +1,10 @@ -{-# options_ghc -Wno-orphans #-} +{-# OPTIONS_GHC -Wno-orphans #-} module Iri.Orphans.Aeson.FromJSON () where import Autodocodec (Autodocodec (..)) import Data.Aeson (FromJSON) import Iri.Data (HttpIri) -import Iri.Orphans.Autodocodec.HasCodec() +import Iri.Orphans.Autodocodec.HasCodec () deriving via Autodocodec HttpIri instance FromJSON HttpIri diff --git a/test/Iri/Orphans/QuickCheck/ArbitrarySpec.hs b/test/Iri/Orphans/QuickCheck/ArbitrarySpec.hs index cffbfaf..595203d 100644 --- a/test/Iri/Orphans/QuickCheck/ArbitrarySpec.hs +++ b/test/Iri/Orphans/QuickCheck/ArbitrarySpec.hs @@ -4,13 +4,12 @@ module Iri.Orphans.QuickCheck.ArbitrarySpec import Prelude -import Test.Hspec - import Data.List (intercalate) import Iri.Data (HttpIri (..)) +import Iri.Orphans.QuickCheck () import Iri.Parsing.Text qualified import Iri.Rendering.Text qualified -import Iri.Orphans.QuickCheck() +import Test.Hspec import Test.QuickCheck (counterexample, property) spec :: Spec From 5c60b8f7d5ee43e884eb35805bf25b64c8b68b45 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 10:37:00 -0600 Subject: [PATCH 15/25] raise 'ip' bound --- stack-lts21.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/stack-lts21.yaml b/stack-lts21.yaml index dbce65d..52d60df 100644 --- a/stack-lts21.yaml +++ b/stack-lts21.yaml @@ -2,6 +2,7 @@ resolver: lts-21.25 extra-deps: - debug-print-0.2.0.0 + - ip-1.7.8 - iri-0.5.1.1 - text-builder-1.0.0.3 - text-builder-core-0.1.1.1 From 0f744f21aa6df13d2cc6b8eb891acc9b07a58a2b Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 12:09:32 -0600 Subject: [PATCH 16/25] nixfmt --- flake.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 2040717..234e18c 100644 --- a/flake.nix +++ b/flake.nix @@ -32,13 +32,12 @@ }; devShells.default = nixpkgs.stable.mkShell { - buildInputs = with (nixpkgs.stable); [ - zlib - ]; + buildInputs = with (nixpkgs.stable); [ zlib ]; nativeBuildInputs = with (packages); [ fourmolu ghc + nixpkgs.stable.nixfmt-rfc-style ]; shellHook = '' From 4b012c96c81a4cd484ca76ed1d2695326f8f31e8 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 12:34:51 -0600 Subject: [PATCH 17/25] bump debug-print --- stack-lts21.yaml | 2 +- stack-lts22.yaml | 2 +- stack-lts23.yaml | 2 +- stack-nightly.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stack-lts21.yaml b/stack-lts21.yaml index 52d60df..30200e8 100644 --- a/stack-lts21.yaml +++ b/stack-lts21.yaml @@ -1,7 +1,7 @@ resolver: lts-21.25 extra-deps: - - debug-print-0.2.0.0 + - debug-print-0.2.0.1 - ip-1.7.8 - iri-0.5.1.1 - text-builder-1.0.0.3 diff --git a/stack-lts22.yaml b/stack-lts22.yaml index 88170c3..385e619 100644 --- a/stack-lts22.yaml +++ b/stack-lts22.yaml @@ -1,7 +1,7 @@ resolver: lts-22.43 extra-deps: - - debug-print-0.2.0.0 + - debug-print-0.2.0.1 - iri-0.5.1.1 - text-builder-1.0.0.3 - text-builder-core-0.1.1.1 diff --git a/stack-lts23.yaml b/stack-lts23.yaml index e7ab147..63e1898 100644 --- a/stack-lts23.yaml +++ b/stack-lts23.yaml @@ -1,7 +1,7 @@ resolver: lts-23.19 extra-deps: - - debug-print-0.2.0.0 + - debug-print-0.2.0.1 - iri-0.5.1.1 - text-builder-1.0.0.3 - text-builder-core-0.1.1.1 diff --git a/stack-nightly.yaml b/stack-nightly.yaml index ad86e7d..b7754e7 100644 --- a/stack-nightly.yaml +++ b/stack-nightly.yaml @@ -1,7 +1,7 @@ resolver: nightly-2025-04-24 extra-deps: - - debug-print-0.2.0.0 + - debug-print-0.2.0.1 - iri-0.5.1.1 - text-builder-1.0.0.3 - text-builder-core-0.1.1.1 From f772fa01ec3f55822668dee7d69690f4375aec00 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 13:13:19 -0600 Subject: [PATCH 18/25] Update renovate.json Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- renovate.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/renovate.json b/renovate.json index bd84589..8efcb83 100644 --- a/renovate.json +++ b/renovate.json @@ -1,7 +1,5 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "local>freckle/renovate-config" - ], + "extends": ["local>freckle/renovate-config"], "minimumReleaseAge": "0 days" } From 4f1608060ba4cd2d7b49445748709b7e2d70fd96 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 14:01:34 -0600 Subject: [PATCH 19/25] bump hspec --- stack-lts21.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stack-lts21.yaml b/stack-lts21.yaml index 30200e8..03d6143 100644 --- a/stack-lts21.yaml +++ b/stack-lts21.yaml @@ -2,6 +2,8 @@ resolver: lts-21.25 extra-deps: - debug-print-0.2.0.1 + - hspec-2.11.10 + - hspec-core-2.11.10 - ip-1.7.8 - iri-0.5.1.1 - text-builder-1.0.0.3 From 730189001215356a406324fbb3a90ce1b9538b75 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 14:02:54 -0600 Subject: [PATCH 20/25] add openapi3 to nightly --- stack-nightly.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/stack-nightly.yaml b/stack-nightly.yaml index b7754e7..d8b8c8f 100644 --- a/stack-nightly.yaml +++ b/stack-nightly.yaml @@ -3,5 +3,6 @@ resolver: nightly-2025-04-24 extra-deps: - debug-print-0.2.0.1 - iri-0.5.1.1 + - openapi3-3.2.4 - text-builder-1.0.0.3 - text-builder-core-0.1.1.1 From 865d45d23ed2b76167926af9cb6304568fa72917 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 14:09:11 -0600 Subject: [PATCH 21/25] Revert "add openapi3 to nightly" This reverts commit 730189001215356a406324fbb3a90ce1b9538b75. --- stack-nightly.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/stack-nightly.yaml b/stack-nightly.yaml index d8b8c8f..b7754e7 100644 --- a/stack-nightly.yaml +++ b/stack-nightly.yaml @@ -3,6 +3,5 @@ resolver: nightly-2025-04-24 extra-deps: - debug-print-0.2.0.1 - iri-0.5.1.1 - - openapi3-3.2.4 - text-builder-1.0.0.3 - text-builder-core-0.1.1.1 From 0e9d2fc21b5ad780e79581550ce3049c390a4280 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 14:09:58 -0600 Subject: [PATCH 22/25] bump more hspec --- stack-lts21.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stack-lts21.yaml b/stack-lts21.yaml index 03d6143..7ccf1a1 100644 --- a/stack-lts21.yaml +++ b/stack-lts21.yaml @@ -4,6 +4,8 @@ extra-deps: - debug-print-0.2.0.1 - hspec-2.11.10 - hspec-core-2.11.10 + - hspec-discover-2.11.10 + - hspec-expectations-0.8.4 - ip-1.7.8 - iri-0.5.1.1 - text-builder-1.0.0.3 From 9b282af93f3cbaae70044a00c48f533b169659ff Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 15:05:39 -0600 Subject: [PATCH 23/25] bump hspec-junit-formatter --- stack-lts21.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/stack-lts21.yaml b/stack-lts21.yaml index 7ccf1a1..8efbd3f 100644 --- a/stack-lts21.yaml +++ b/stack-lts21.yaml @@ -6,6 +6,7 @@ extra-deps: - hspec-core-2.11.10 - hspec-discover-2.11.10 - hspec-expectations-0.8.4 + - hspec-junit-formatter-1.1.2.1 - ip-1.7.8 - iri-0.5.1.1 - text-builder-1.0.0.3 From abca68410fe80a924f1e71b8ac1ed0504e637ce8 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 24 Apr 2025 15:07:52 -0600 Subject: [PATCH 24/25] bump hspec-api --- stack-lts21.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/stack-lts21.yaml b/stack-lts21.yaml index 8efbd3f..292a908 100644 --- a/stack-lts21.yaml +++ b/stack-lts21.yaml @@ -2,6 +2,7 @@ resolver: lts-21.25 extra-deps: - debug-print-0.2.0.1 + - hspec-api-2.11.10 - hspec-2.11.10 - hspec-core-2.11.10 - hspec-discover-2.11.10 From 53de8262762859b69a605474325a6ee11d3c924a Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Sun, 27 Apr 2025 01:57:24 -0600 Subject: [PATCH 25/25] improve Arbitrary --- iri-orphans.cabal | 1 - package.yaml | 1 - src/Iri/Orphans/QuickCheck/Arbitrary.hs | 134 ++++++++++++++++++++---- 3 files changed, 116 insertions(+), 20 deletions(-) diff --git a/iri-orphans.cabal b/iri-orphans.cabal index 78ddaae..665858b 100644 --- a/iri-orphans.cabal +++ b/iri-orphans.cabal @@ -76,7 +76,6 @@ library , aeson , autodocodec , base <5 - , bytestring , debug-print , generic-arbitrary , ip diff --git a/package.yaml b/package.yaml index 827e1cb..ae5f179 100644 --- a/package.yaml +++ b/package.yaml @@ -74,7 +74,6 @@ library: dependencies: - aeson - autodocodec - - bytestring - debug-print - generic-arbitrary - ip diff --git a/src/Iri/Orphans/QuickCheck/Arbitrary.hs b/src/Iri/Orphans/QuickCheck/Arbitrary.hs index 19016bb..01c4e67 100644 --- a/src/Iri/Orphans/QuickCheck/Arbitrary.hs +++ b/src/Iri/Orphans/QuickCheck/Arbitrary.hs @@ -4,41 +4,139 @@ module Iri.Orphans.QuickCheck.Arbitrary () where import Prelude -import Data.ByteString qualified as BS import Data.Text qualified as T +import Data.Text.Encoding qualified as T import Data.Vector qualified as V -import Data.WideWord.Word128 import Iri.Data -import Net.IPv4 -import Net.IPv6 + ( DomainLabel (..) + , Fragment (..) + , Host (..) + , HttpIri + , Path (..) + , PathSegment (..) + , Port + , Query (..) + , RegName (..) + , Security (..) + ) +import Test.QuickCheck + ( Arbitrary + , Gen + , arbitrary + , choose + , elements + , listOf + , listOf1 + , oneof + ) import Test.QuickCheck.Arbitrary.Generic -import Test.QuickCheck.Gen (choose, listOf, listOf1) - -deriving via GenericArbitrary HttpIri instance Arbitrary HttpIri -deriving via GenericArbitrary Port instance Arbitrary Port -deriving via GenericArbitrary Word128 instance Arbitrary Word128 - -deriving newtype instance Arbitrary IPv4 -deriving newtype instance Arbitrary IPv6 -deriving newtype instance Arbitrary Security + ( GenericArbitrary + , genericArbitrary + ) +import Test.QuickCheck.Arbitrary.Generic qualified instance Arbitrary DomainLabel where - arbitrary = DomainLabel . T.pack <$> listOf1 (choose ('a', 'z')) + arbitrary = DomainLabel . T.pack <$> listOf1 char + where + char = + oneof + [ choose ('a', 'z') + , choose ('A', 'Z') + , choose ('0', '9') + , elements "-_~!$&'()*+,;=" + ] instance Arbitrary Fragment where - arbitrary = Fragment . BS.pack <$> listOf (choose (97, 122)) + arbitrary = Fragment . T.encodeUtf8 . T.pack <$> listOf char + where + char = + oneof + [ choose ('a', 'z') + , choose ('A', 'Z') + , choose ('0', '9') + , elements "-._~:@/?|" + , ucs + ] instance Arbitrary Host where - arbitrary = NamedHost <$> arbitrary + -- Don't generate an IPv6 host because + -- https://github.com/nikita-volkov/iri/issues/2 + arbitrary = + oneof + [ NamedHost <$> arbitrary + , IpV4Host <$> genericArbitrary + ] + +deriving via + GenericArbitrary HttpIri + instance + Arbitrary HttpIri instance Arbitrary Path where arbitrary = Path . V.fromList <$> listOf arbitrary instance Arbitrary PathSegment where - arbitrary = PathSegment . BS.pack <$> listOf1 (choose (97, 122)) + arbitrary = PathSegment . T.encodeUtf8 . T.pack <$> listOf1 char + where + char = + oneof + [ choose ('a', 'z') + , choose ('A', 'Z') + , choose ('0', '9') + , elements "-._~:@" + , ucs + ] + +deriving via + GenericArbitrary Port + instance + Arbitrary Port instance Arbitrary Query where - arbitrary = Query . BS.pack <$> listOf (choose (97, 122)) + arbitrary = Query . T.encodeUtf8 . T.pack <$> listOf1 char + where + char = + oneof + [ choose ('a', 'z') + , choose ('A', 'Z') + , choose ('0', '9') + , elements "-._~:@/?|" + , ucs + , private + ] instance Arbitrary RegName where arbitrary = RegName . V.fromList <$> listOf1 arbitrary + +deriving newtype instance + Arbitrary Security + +ucs :: Gen Char +ucs = + oneof + [ choose ('\xA0', '\xD7FF') + , choose ('\xF900', '\xFDCF') + , choose ('\xFDF0', '\xFFEF') + , choose ('\x10000', '\x1FFFD') + , choose ('\x20000', '\x2FFFD') + , choose ('\x30000', '\x3FFFD') + , choose ('\x40000', '\x4FFFD') + , choose ('\x50000', '\x5FFFD') + , choose ('\x60000', '\x6FFFD') + , choose ('\x70000', '\x7FFFD') + , choose ('\x80000', '\x8FFFD') + , choose ('\x90000', '\x9FFFD') + , choose ('\xA0000', '\xAFFFD') + , choose ('\xB0000', '\xBFFFD') + , choose ('\xC0000', '\xCFFFD') + , choose ('\xD0000', '\xDFFFD') + , choose ('\xE1000', '\xEFFFD') + ] + +private :: Gen Char +private = + oneof + [ choose ('\xE000', '\xF8FF') + , choose ('\xF0000', '\xFFFFD') + , choose ('\x100000', '\x10FFFD') + ]