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

Editor Componentization #1297

Merged
merged 152 commits into from
Dec 11, 2024
Merged

Editor Componentization #1297

merged 152 commits into from
Dec 11, 2024

Conversation

Negabinary
Copy link
Contributor

@Negabinary Negabinary commented Apr 30, 2024

Editor Componentization

Warning: this is a huge change to the Haz3lweb portion of the codebase. I've tried to provide a guide below for merging this into your branch.

There are more details in docs/ui-architecture.md.

Motivation:

The goal of this refactor is to turn Haz3lWeb into a tree of re-usable, independent components. There is both a short-term, and long-term motivation to do this.

image

In the short-term, being able to re-use the editors, and statics highlighting in particular will allow us to select / edit outputs. This is important for the interactions that will be in the proof stepper but also for the flexibility to copy results back into code etc.

In the long-term, this componentization gets us closer to good coding practices in the hazel codebase. It creates a separation of concerns where each component can consider only its local state/updates, instead of needing to worry about global state/update.

The Big Changes

  • A lot of files in Haz3lweb have moved. I'm hoping git will handle this automatically.

  • Model.re, UpdateAction.re and Update.re have been deleted. Each component of the UI now has its own Model and Update modules. If you had added any actions to UpdateAction.re, you will now want to add them to the Update module of the component in the ui tree "where the action takes place".

  • DHDoc_Exp, and other functions for printing dynamic expressions are gone. Anything that was previously output that way will need to be output using one of the following:

    • new syntax in user expressions (e.g. users can now type fix, but this allows us to show them in output)
    • static errors (e.g. failed casts are now shown using static type errors in the results)
    • or wait until Leaf Projectors #1218 is merged in (e.g. we'll use projectors to hide functions when projectors are merged in)

Design:

Each component is a file that contains four modules:

  • Model: stores the model of this component, along with initializers and serialization methods
  • Update: gives the available actions on this component, and functions that perform those actions. There is also a function to re-calculate all the dependent data.
  • Selection: has methods for working out which editor on a screen is currently "active" and dispatches key events to the correct place
  • View: has methods for viewing the model and connecting up actions to the correct update.

Pre-existing Dev bugs which became more obvious

let odd: Int -> Bool =
 fun n -> if n == 0 then true else odd( ) 
in odd(5)
let f : Int -> Int = fun x -> x in
f
let odd: Int -> Bool =
 fun n -> if n == 0 then true else odd( ) 
in odd(5)

Wontfixes:

  • Steppers don't save (doesn't seem important to save it at the moment)
  • Dynamic errors don't show up (e.g. divide by zero)

@Negabinary Negabinary changed the base branch from dev to remove-dhexp April 30, 2024 20:20
@Negabinary Negabinary linked an issue May 1, 2024 that may be closed by this pull request
@Negabinary Negabinary mentioned this pull request May 1, 2024
@Negabinary Negabinary linked an issue May 2, 2024 that may be closed by this pull request
@cyrus- cyrus- marked this pull request as ready for review December 11, 2024 19:44
@cyrus- cyrus- merged commit 781f253 into dev Dec 11, 2024
2 checks passed
@cyrus- cyrus- deleted the editor-output branch December 11, 2024 19:46
@cyrus- cyrus- mentioned this pull request Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants