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

Draft
wants to merge 117 commits into
base: dev
Choose a base branch
from
Draft

Editor Componentization #1297

wants to merge 117 commits into from

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.

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.

Closed Bugs:

  • ExplainThis drop-down doesn't work
  • School mode evaluation doesn't always work, and is slow
    • specifically YourTestsTesting doesn't evaluate
    • Mutation testing doesn't evaluate
  • Spacing around output code is not consistent
  • Casts are not output
  • Holes don't print in cursor info types
  • (let x = 4 in x) + 3 stops in stepper
  • exception when opening ADT Dynamics
  • projectors are not interactive
  • A weird dotted line has appeared around the code editor
  • Hiding functions doesn't currently work
  • Export persistent data
  • Folded things in select-only editor won't show
  • CSS: selection is in front of text
  • Statics isn't running on output
  • Stepper formatting has gone black
  • Exercises formatting
  • Selecting prelude in exercises
  • Test validation feedback is not correct
  • Things don't update after settings
  • Tab insertion not working (in exercises) (Same issue as below! Have asked Andrew)
  • Up gives non-red exception, Up then Left causes it to crash (in exercises)
  • type T = + A + B in let x : T = in case x | A => 1 | B => 2 end
    elaboration has constructor errors
  • projectors are missing on the stepper
  • 5:Int + 5:Float
  • cursor can't move through results
  • cursor can't move through stepper
  • extra space between ) (
  • function hiding projector should say it's a function
  • TyDi is disabled (projectors should change how this works anyway)
  • Outputting sum constructors somehow

Open Bugs:

Projector Issues:

  • find a way to hide type annotations
  • projector with multiline internals don't always work e.g. folding the function below, then drag around the folded function.
let f =
 (fun x -> 
 let y = 5 in )
in 

Update Issues:

  • stepper doesn't update with settings
  • stepper recalculating cursor position too often
  • randomly autocompleting when you click around
  • don't clear test results on edit

Printing Issues:

  • underline is missing middle segment
  • stepped lines are green
  • fixpoint + appearing too often in function names

Other:

  • "could not use get_log_and outside of the main viewport"

Wontfixes:

  • Steppers don't save (doesn't seem important to save it at the moment)

todo: check that I haven't broken:

  • Assistant / Resetting Assistant
  • School mode secrecy

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants