Skip to content

Add TermGenerator for writing constrainable custom generators - #224

Draft
Soupstraw wants to merge 12 commits into
masterfrom
jj/generator-controls
Draft

Soupstraw wants to merge 12 commits into
masterfrom
jj/generator-controls

Conversation

@Soupstraw

@Soupstraw Soupstraw commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

This PR changes how control operators are applied to rules. Previously we had a genControl function which had cases for all the implemented control operator behavior. Since we want custom generators to also be able to be affected by constraints, I moved the constraint application into the generators themselves.

The generators now use TermGenerator, which has both the generator and a mutator function, which takes a constraint and applies it to the generator to produce a more constrained TermGenerator. The users now have two different interfaces for implementing custom generators: withCBORGen and withGenerator. The withCBORGen is a simpler interface, which just takes a generator, but it will fail whenever any callsite tries to apply a constraint to the rule that has a withCBORGen generator attached to it. For rules that will need to be affected by constraints, it is possible to define custom generators using withGenerator.

close #223

@Soupstraw
Soupstraw force-pushed the jj/generator-controls branch from b8e9e56 to 4bcf73f Compare November 18, 2026 13:20
@Soupstraw
Soupstraw force-pushed the jj/generator-controls branch from 4bcf73f to d380eae Compare November 18, 2026 13:49
@Soupstraw
Soupstraw force-pushed the jj/generator-controls branch from d380eae to 9c7a9c9 Compare November 18, 2026 13:53
Comment thread src/Codec/CBOR/Cuddle/CBOR/Gen.hs Resolved
@Soupstraw Soupstraw changed the title Jj/generator controls Add TermGenerator for writing constrainable custom generators Nov 19, 2026
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.

Give custom generators access to the constraints

1 participant