Draft
Conversation
This was referenced Apr 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is my first attempt at sketching how I'd like to abstract over state as proposed in #60.
This code does not compile yet. This PR is meant as a request for early feedback on whether I should continue in this direction.
A few notes:
next newStateExpressionbynewStateExpression |> next. The pipeline operator is defined in the Lean standard library and I didn't have to add any import or notation-scope-opening to activate it.StatusFlagsrecord could be removed by using setters for the individual flags, but I kept it because it seems to me that the code tries to defend against accidential omission of a flag, and keeping theStatusFlagsrecord seems to helps towards that goal, but I'm not sure if it's worth keeping these records.(λ setcf => ...)invokesetcftwice, so after a beta reduction, the whole body ofsetcfis duplicated. With this PR, the duplication should be gone, but it now uses a different setter to set specific values than to set an undefined value. I believe it would be best to push theifas far down as possible, all the way into the argument of the setter, likeStatusFlag.cf.set (if cond then specificValue else undefinedValue). As far as I can tell, neither the code before this PR nor this PR achieves this. If someone comes up with a solution that achieves this using theUndefinedtypeclass instead ofundefineXmethods onStateAccess, I'll be happy to accept this as an indicator that myundefineXmethods onStateAccesswere a bad idea ;)