-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Implement Multiple-Choice Reading Option #81
Comments
@initial-mockingbird Thanks for putting so much time into the design specification! I'll need some time to think if it's possible to come up with a simpler design 🤔 Another few points that need refinement:
Also, this can be done separately but I needed in the past the ability to specify several values by the multiple-choice option. Would be nice if this can be easily supported by a single representation but I also see the value in keeping the interface simple for users. |
@chshersh Thank you for taking the time to review everything so thoughtfully!
The value between the
You are right! maybe a quick fix would be to turn the
Sadly, I don't really see how to incorporate this into the current proposal :( (how would the user input multiple choices?). Nevertheless, maybe a better design than the one I proposed would fall along the lines of the GHCUP TUI menu? i.e:
This means that:
Thus, the design would end up being: -- tag in case one wants to receive multiple answes
data Mode = SingleAnswer | MultipleAnswer
data MultipleChoiceOption a = MultipleChoiceOption
{ displayName :: ByteString
, initiallyActive :: Bool -- which options should be active by default?
, value :: a -- no more parsing!
}
data MultipleChoicePrompt a = MultipleChoicePrompt
{ promptMessage :: ByteString
, promptOptions :: NonEmpty (MultipleChoiceOption a)
, mode :: Mode
}
multipleChoiceQuestion
:: MonadIO m
=> MultipleChoicePrompt a
-> m (NonEmpty a) And then we can expose things like Yes/No questions, as partial application of As a final note, I think this would benefit from the ncurses library. Caveats:
|
Iris focuses only on CLI, not TUI. So TUI-inspired interfaces are out of scope for this project. And we won't benefit from
I would be pretty happy to have a separate As for the design of this feature, I'm still not satisfied. But I need to think about the better design 🤔 |
A generalization for #9 .
The choices can be modeled as their display name coupled with a parsing function to the desired data type of the answer:
Then, we can model multiple choices as: a message prompt, a non-empty list of choices (whose default choice will always be the head), and a value for the default option:
Thus, the following prompt data:
Will represent:
Finally, we can define a function that:
MultipleChoicePrompt
foldMap
over theAlt
monoid)stderr
in case of error, returningNothing
An example run would be:
Something to notice is that the function will take the default value and build a parser to accept empty responses:
Finally, some points that might need refinement:
stderr
and returningNothing
, it may be better to returnEither Bytestring a
and let another function decide what to do.Non-Empty
List, we could have either a tuple with the first two options and a normalList
for the rest, or a sized container (i.e, something from Data.Size). Having a multiple option question with just one option feels wrong.I'm willing to try and accommodate all suggestions to this implementation :)
The text was updated successfully, but these errors were encountered: