Skip to content

Conversation

@dfordivam
Copy link
Collaborator

  • Removes use of existentials. fixes Remove existential types in TUI #1217

  • Makes use of GHC.Generics to take care of the Menu boilerplate

  • Improves the structure of code as each widget now need to implement the instance of BaseWidget, which captures the two essential parts, rendering and event handling.

  • The structure of the widget state matches directly to the "tree" structure of widgets. And the use of enums, like Mode, have been removed.

  • The input fields are more generic and we can nest them, like EditInput is being used inside SelectInput

  • The value of input fields can be modified like this

  compileGHCMenu % innerWidget % GenericMenu.fields % CompileGHCMenu.installTargetsF % EditInput.editInputOverlay % innerWidget % EditInput.editor %~ Edit.applyEdit (const (textZipper ["new-value"] Nothing))
  • The child widget does not modify the state of parent (as it was earlier being done via lens)

  • The 'quit' key handling logic is now mostly part of the BasicOverlay abstraction, and has been removed from the event handlers of individual widgets.

  • We can even do nesting of GenericMenu, in case we want to make fancy sub-menus

@dfordivam dfordivam requested a review from lsmor April 21, 2025 13:53
Copy link
Collaborator

@lsmor lsmor left a comment

Choose a reason for hiding this comment

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

I am not able to fully review this as the code is way more complex than my knowledge 😅 . My understading is:

  • Menus are defined by two parallel datatypes The "Fields" + "Options", and then this GenericMenu thing which I barely understand... Instead of Having "Options" + list of fields as before.
  • Existentials are hidden behind TypeClasses + Data.Some if I understand correctly.
  • I don't get the Overlays part. AFAIU, brick dispatches events to the frontward layers, so there is no need to pass events to the "child"/overlayed widget... but maybe I got this wrong

@dfordivam
Copy link
Collaborator Author

dfordivam commented Apr 28, 2025

@lsmor Unfortunately the changes here did become big and complex. They can be seen as two major parts

The first is the BaseWidget class which describes the overlay functionality, including the passing of events to the widget which is currently open. (brick unfortunately has no concept of passing events to frontward layers)
The second is the GenericMenu which uses GHC.Generic, and does not make use of list of fields with existentials.

I guess the main thing to review here is how the new design is being used and how more features/widgets could be added.

In this commit I have implemented a confirmation prompt for pre-install messages using this new design. Implementing this in the earlier design would have been far more complex.

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.

Remove existential types in TUI

3 participants