Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions LSpec/SlimCheck/Sampleable.lean
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,14 @@ class SampleableExt (α : Sort u) where
sample : Gen proxy
interp : proxy → α

attribute [instance] SampleableExt.proxyRepr
attribute [instance] SampleableExt.shrink
attribute [reducible, instance] SampleableExt.proxyRepr
attribute [reducible, instance] SampleableExt.shrink

namespace SampleableExt

/-- Use to generate instance whose purpose is to simply generate values
of a type directly using the `Gen` monad -/
@[reducible]
def mkSelfContained [Repr α] [Shrinkable α] (sample : Gen α) : SampleableExt α where
proxy := α
proxyRepr := inferInstance
Expand Down Expand Up @@ -176,6 +177,7 @@ instance Bool.sampleableExt : SampleableExt Bool :=
/-- This can be specialized into customized `SampleableExt Char` instances.
The resulting instance has `1 / length` chances of making an unrestricted choice of characters
and it otherwise chooses a character from `chars` with uniform probabilities. -/
@[reducible]
def Char.sampleable (length : Nat) (chars : Array Char) : SampleableExt Char :=
mkSelfContained do
let x ← choose Nat 0 length
Expand Down
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lean-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
leanprover/lean4:v4.28.0
leanprover/lean4:v4.29.0
Loading