an extenstion that runs a better error compiler for Ocaml based on the article: Getting Into The Flow: Better Type Error Messages for Constraint-Based Type Inference This is the FrontEnd extension side.
for the backend server that runs and creates the dataflow errors, go to this repository
- a built-into the extension Ocaml Interpreter with command and evaluation separator, error and warnings, and color coding. for best use, separate blocks with ';;' at the end.
- An interactive AST tree visualizer.
- Data Flow Type Error messages / information. (Needs the Backend Server activated locally from here)
- LLM based solution and explanation to all the errors and warning in the code.
IMPORTANT: The API key for the LLMs uses a free plan, it would be best for you to get your own free plan API key from gemini, so you dont get limited easily. you can change it in src/ai_communication.ts. you can also use a paid plan key if you have one. you can change the LLM version used easily as well.
Link to HD video on youtube
test_showcase_comp.mp4
Link to HD video on youtube
BEC.Demo.mp4
- Install Ocaml by following https://fdopen.github.io/opam-repository-mingw/installation/
- Ocaml version 4.14.0 preferable (ocaml-variants.4.14.0+mingw64c)
- Intall lsp-ocaml-server, dune and utop packages.
- Make sure dune is installed / written in installation line prior to lsp and utop, as both of them use it.
- Utop version: 2.10.0
- Install Ocaml Platform Extenstion in VSCode.
- Clone the BackEnd Repo and run it locally
in VSCode, you can use Ocaml Platfrom to make sure your switch is set up correctly.
Clone the repository.
- open vscode terminal, use npm install
- use npm run compile and wait for it to finish
- make sure to have started vscode through cygwin terminal
- in Ocaml Platform, choose your preferred switch, that has utop and ocaml on it
- click on F5 to run in debug mode if you want to view console log for unexpected errors
- run in non debug mode for normal uses
After starting, a new VSCode window will open, the extension will be available for use in this new window only!
Go To BackEnd repo
follow the ReadMe there to download.
TL:DR; you need to have cursior / sbt downloaded Java version between 11-19 to use with it
- use CMD, vscode terminal or intellij terminal (or other IDEs)
- Type sbt and enter
- when SBT opens, write run and enter
this will run the server on port 8080, make sure to close the server properly so you dont get issues next time you run it
read the 'ReadMe' in the server folder on this repo, and follow along.
to use properly, make sure to have your vscode page has been fully loaded before using extension
-
create or open an ocaml file.
-
end commands with ';;' for optimal results.
-
make sure the ocaml file you want is the active editor.
-
use the bottom bar 'BEC' button, 'ctrl+alt+b' or 'cmd+opt+b', or open the command pallete and search for BEC.
BEC-Bar:
the fullscreen button allows you to change freely between full tab size and side tab size
-
'recompile file': recompiles the ocaml file that was in active editor when the extension was activated and not the file currently in the active editor.
-
'interpreter results': show the interpreter results for the entire file even if errors occur
- groups each command with its evaluations, errors, warning and hints together
- make sure to separate code blocks with ';;', so that they can be grouped separately
- uses colors to make it easier to view errors, warnings and hints.
- in errors and warnings, the Line number corresponds to location relative to current command
If the page is stuck in loading, try to recompile
- groups each command with its evaluations, errors, warning and hints together
-
'data flow errors': shows the errors using Data Flow Errors based on the article:
Needs the backend server activated
Getting Into The Flow: Better Type Error Messages for Constraint-Based Type Inference (Artifact)
to view article Github page, click here
-
'AI error details': uses Gemini LLM to explain the errors, its origin, dataflow and suggest a solution to the error. This is done for all the errors and warning in the interepreter results.
The results are showcases in section, and you can close each section by clicking on the button above it. A light blue means the section is open, while a gray means it is closed.
as LLMs arent always consistent, you might see small changes in response design, or might not be satified with resutls if so, click the 'try again' button to rerun the request.
-
'view AST results': opens a new tab and shows an interactive AST tree graph.
the graph preparation could take up to a minute, please be patient
- each block includes node value, type and params if applicable
- if a node has children, and arrow and a number can be seen at the bottom of it. when clickd upon. it opens the view to show the direct children of this node. childrent can have children of their own.
- can use 'highlight node' and 'highlight node to root' options with the Node ID text
- a search function which highlights blocks with the name of the searched value: