Skip to content
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

Experiment: make ref wrappers optional #144

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dpwiz
Copy link
Member

@dpwiz dpwiz commented Mar 23, 2022

Replace mutable ref + changed flag for monadic action yielding the change.

StateRef behaviour is trivially recovered with a maybe-to-set/bool wrapper and a bunch of binds.

@dpwiz dpwiz added this to the v2 milestone Mar 23, 2022
ref $=! (newValue == 1)

return changed
checkbox label ref = stateful ref $ checkboxM label
Copy link
Member Author

Choose a reason for hiding this comment

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

The wrapped functions aren't even needed if widgets are to have their "mutable" arguments stated last.

There can be statefulN-family for widgets that mutate N arguments at once.

-- With all arguments expanded
dragFloatRange2 desc speed minValue maxValue minFmt maxFmt refMin refMax = ...

-- Just add your values
dragFloatRange01 label = dragFloatRange2 label 0.01 0 1 "%.1f" "%.1f"

action rMin rMax = do
  changed <- stateful2 rMin rMax $
    dragFloatRange01 "from zero to hero"
  when changed do
    ...

@dpwiz dpwiz modified the milestones: v2, v3 Jul 25, 2022
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.

1 participant