一键导入
hedgehog
Guidelines for property-based tests for Haskell using Hedgehog. Use when writing or reviewing property-based tests in Haskell.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Guidelines for property-based tests for Haskell using Hedgehog. Use when writing or reviewing property-based tests in Haskell.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Guides for Haskell code. Use when writing Haskell code.
Replace lens with microlens-* in Haskell packages
Security audit checklist for Rust code. Use when auditing Rust code for security vulnerabilities.
Re-generate Cabal freeze files.
Improve performance of Haskell code. Use when asked to profile or improve performance.
Reviews Haskell comments for Haddock markup opportunities. Use when reviewing or improving Haskell documentation comments.
| name | hedgehog |
| description | Guidelines for property-based tests for Haskell using Hedgehog. Use when writing or reviewing property-based tests in Haskell. |
if, unless, when) when preconditions
aren't met, use ==> or discard from Hedgehog.==.Ensure that every nontrivial typeclass instance has tests for each of the following properties:
Eq
x == xx == y ==> y == xx == y && y == z ==> x == zOrd
x <= y && y <= x ==> x == yx <= y && y <= z ==> x <= zx <= y || y <= xcompare x y == EQ ==> x == yEq1
liftEq (==) x y == (x == y)Ord1
liftCompare compare x y == compare x yHashable
x == y ==> hash x == hash yFunctor
fmap id == idfmap (f . g) == fmap f . fmap gApplicative
pure id <*> v == vpure (.) <*> u <*> v <*> w == u <*> (v <*> w)pure f <*> pure x == pure (f x)u <*> pure y == pure ($ y) <*> uMonad
return x >>= f == f xm >>= return == m(m >>= f) >>= g == m >>= (\x -> f x >>= g)Traversable
traverse Identity == Identitytraverse (Compose . fmap g . f) == Compose . fmap (traverse g) . traverse fBifunctor
bimap id id == idbimap (f . g) (h . i) == bimap f h . bimap g iBitraversable
bitraverse (Identity . f) (Identity . g) == Identity . bimap f gbitraverse (Compose . fmap g . f) (Compose . fmap i . h) == Compose . fmap (bitraverse g i) . bitraverse f hSemigroup
(x <> y) <> z == x <> (y <> z)Monoid
x <> mempty == xmempty <> x == x(x <> y) <> z == x <> (y <> z)Alternative
empty <|> x == xx <|> empty == x(x <|> y) <|> z == x <|> (y <|> z)MonadPlus
mzero >>= f == mzerom >> mzero == mzero| Property | Formula | When to Use |
|---|---|---|
| Roundtrip | decode(encode(x)) == x | Serialization, conversion pairs |
| Idempotence | f(f(x)) == f(x) | Normalization, formatting, sorting |
| Invariant | Property holds before/after | Any transformation |
| Commutativity | f(a, b) == f(b, a) | Binary/set operations |
| Associativity | f(f(a,b), c) == f(a, f(b,c)) | Combining operations |
| Identity | f(x, identity) == x | Operations with neutral element |
| Inverse | f(g(x)) == x | encrypt/decrypt, compress/decompress |
| Oracle | new_impl(x) == reference(x) | Optimization, refactoring |
| Easy to Verify | is_sorted(sort(x)) | Complex algorithms |
| No Exception | No crash on valid input | Baseline property |
Strength hierarchy (weakest to strongest): No Exception → Type Preservation → Invariant → Idempotence → Roundtrip