./hello.byte
Again, if you install OCaml natively in Windows, you can run:
.\hello.exe
Linux uses forward slash to separate directory and Windows uses backslash
./hello.byte
Again, if you install OCaml natively in Windows, you can run:
.\hello.exe
Linux uses forward slash to separate directory and Windows uses backslash
ocamlc -o hello.byte hello.ml
If you install OCaml natively in Windows (not using WSL), I think you can directly run:
ocamlc -o hello.exe hello.ml
Previous instructions in installing: https://hyp.is/4XRZ3EKyEfCr8--I_WXR9w/cs3110.github.io/textbook/chapters/preface/install.html
“A language that doesn’t affect the way you think about programming is not worth knowing.”
This statement may be a bit misleading. Alan has never recommend ML language in his life, instead he indeed recommends to use LiSP language.
Unix development in Windows
I dig through the documentation and have written this guide for Windows user that don't want to use WSL
This guide explains how to set up a native OCaml development environment on Windows using PowerShell. You will install the latest PowerShell (pwsh), Git, and opam (the OCaml package manager) along with some essential OCaml-related tools. Finally, you will configure your PowerShell profile so OCaml is available every time you launch a new session.
PowerShell 7 is recommended since it comes with new features and improvements compared to Windows PowerShell 5.1. Note that PowerShell 7 installs as pwsh.exe (instead of the legacy powershell.exe).
pwsh.exe.Git is required as a dependency for many OCaml tools. Download the latest x64 setup for Windows:
opam is the OCaml package manager and is the recommended way to manage OCaml installations on Windows.
Open PowerShell 7 (pwsh.exe) and execute the following command:
powershell
winget install OCaml.opam
Once the installation completes, initialize opam with:
powershell
opam init
During initialization, you will be asked two questions:
Please note that the initialization process may take a while depending on your computer's performance.
After setting up opam, install additional OCaml tools that will improve your development experience. Run the following command in PowerShell:
powershell
opam install ocaml-lsp-server odoc ocamlformat utop
Like before, the installation time may vary based on your system.
To access your OCaml environment in every PowerShell session, you need to update your PowerShell profile.
For the current session, you can load the opam environment by running:
powershell
(& opam env) -split '\r?\n' | ForEach-Object { Invoke-Expression $_ }
This command sets up the OCaml-related environment variables for the active session only.
Locate Your PowerShell Profile File:<br /> Execute the following command to reveal the profile path:
powershell
$profile
You might receive a path similar to:
C:\Users\<username>\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
Edit (or Create) Your Profile File:
Open the file at the path above.
If the file does not exist, create a new file with the same name (Microsoft.PowerShell_profile.ps1).
Add the following line to the file:
powershell
(& opam env) -split '\r?\n' | ForEach-Object { Invoke-Expression $_ }
Save the file.
Now, every time you launch PowerShell, the OCaml environment will be automatically configured.
To verify that everything is set up correctly:
Open a new PowerShell session.
Launch the OCaml Read-Evaluate-Print Loop (REPL) by typing:
powershell
utop
In the utop prompt, test with a simple expression:
ocaml
21 + 43;;
The REPL should evaluate the expression and return the corresponding result.