Skip to content

Ts constrained manual #4985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Ts constrained manual #4985

wants to merge 5 commits into from

Conversation

TimSheard
Copy link
Contributor

@TimSheard TimSheard commented Apr 14, 2025

First draft of a Manual for constrained generators.
Adds two files to docs/constrained-generators
Manual.md and ManualExamples.hs, which is a executable file with the examples used in Manual.md

  • [x ] Commits in meaningful sequence and with useful messages.
  • [x ] Tests added or updated when needed.
  • CHANGELOG.md files updated for packages with externally visible changes.
    NOTE: New section is never added with the code changes. (See RELEASING.md).
  • Versions updated in .cabal and CHANGELOG.md files when necessary, according to the
    versioning process.
  • Version bounds in .cabal files updated when necessary.
    NOTE: If bounds change in a cabal file, that package itself must have a version increase. (See RELEASING.md).
  • Code formatted (use scripts/fourmolize.sh).
  • Cabal files formatted (use scripts/cabal-format.sh).
  • hie.yaml updated (use scripts/gen-hie.sh).
  • [x ] Self-reviewed the diff.

@TimSheard TimSheard requested a review from a team as a code owner April 14, 2025 02:30
@Soupstraw Soupstraw self-requested a review April 14, 2025 15:16
@TimSheard TimSheard force-pushed the ts-constrained-manual branch 2 times, most recently from a04521c to 9f2bb0c Compare April 15, 2025 21:28
Copy link
Contributor

@Soupstraw Soupstraw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. The formatting of code examples is inconsistent though.

@TimSheard TimSheard force-pushed the ts-constrained-manual branch 4 times, most recently from 8c2b867 to b4d4aee Compare April 16, 2025 20:04
This is a manual of how to use the constrained-generators libray in mark-down
Tries to address every feature that is accessible from Constrained.API and
a bit more.
@TimSheard TimSheard force-pushed the ts-constrained-manual branch from b4d4aee to 9bfb92b Compare April 16, 2025 20:13
Copy link
Contributor

@neilmayhew neilmayhew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm only about halfway through, but I wanted to give you what I have so far. Nothing major, just a lot of little things I noticed.

Copy link
Contributor

@neilmayhew neilmayhew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more interim comments

pure $ (w < x && x < y && y < z) ==> property (w < z)
```

The problem with this is that the probability that the precedant `(w < x && x < y && y < z)` is True, for random
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with the word "precedant" (unless it's a typo for "precedent"). Either way, I think "condition" would be a more familiar term for programmers.

Suggested change
The problem with this is that the probability that the precedant `(w < x && x < y && y < z)` is True, for random
The problem with this is that the probability that the condition `(w < x && x < y && y < z)` is `True`, for random

```

A vacuous pass, becomes a QuickCheck `discard`, so we cannot find 100 successful passes.
We can do a better job by constraining the precedant using `genFromSpec`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
We can do a better job by constraining the precedant using `genFromSpec`
We can do a better job by constraining the input using `genFromSpec`

Comment on lines +326 to +327
Now this isn't a very good test either, since the precedant is alway true. A better solution would be to
generate a mix, where the precedent is True most of the time, but sometimes False.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Now this isn't a very good test either, since the precedant is alway true. A better solution would be to
generate a mix, where the precedent is True most of the time, but sometimes False.
Now this isn't a very good test either, since the condition is always true. A better solution would be to
generate a mix, where the condition is `True` most of the time, but sometimes `False`.

+++ OK, passed 100 tests; 7 discarded.
```
This makes it possible to write conditional 'implication' properties that have a high probability of
not being vacuosly true.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
not being vacuosly true.
not being vacuously true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants