creativescala / doodle-explore

Declarative UI specification for interactive visualization exploration
Apache License 2.0
1 stars 0 forks source link

Design of `ExploreBoolean` allows inconsistent state #3

Closed noelwelsh closed 2 years ago

noelwelsh commented 2 years ago

Presumably to explore a Boolean requires the user to specify if the they're constructing a button or a checkbox (which have different semantics: one produces an instantaneous value and the other is a toggle). The design of the API allows a user to create a instance without specifying this, which seems like it would be an illegal state.

Concretely, calling the boolean method without calling asButton or asCheckbox on the resulting value seems to me like a bug. This possibility could be avoided simply by removing these methods and providing only button and checkbox.

Note that this API / algebra breaks an abstraction boundary. Other algebras only ask the user to specify the type of values (plus, optionally, some constraints) they want to produce. The interpreter then decides how this maps to UI components. This API directly specifies the UI component.

noelwelsh commented 2 years ago

Closed by 6d304294187de118ecea71fbc7241b3851040257