Hi, I have Ocaml switch 4.13.1 running on Mac. utop is working fine, can load the Base module when I do:
#use "topfind";;
#require "base";;
open Base
List.mem ["1"] "1" ~equal:String.equal
even though I followed these instructions Real World OCaml which assume I don’t have even to do open Base, but the VS Code is having a problem loading the Base module. I have OCaml -LSP language server installed for VS code for the switch I have. But when I try the above code, it gives me red error squiggly line under the # of #use "topfind";;. When I remove use and require I get the following error in the screenshot attached. Can you please help with this? I have tried everything since yesterday, I tried to build a project with dune and still in the main the above code have squiggly lines.
A module implementation basically consists of definitions and expressions. The rule is that any expression at the top level of a module implementation has to be separated from previous items by a ;;. Otherwise, in many cases it would be impossible to tell where the previous item stops and the new expression begins.
Binding with let () = turns the expression into a definition, so it’s no longer necessary to use the ;;.
Protip which you will see mentioned a lot in this forum: for newcomers to the language, it’s very helpful to turn on autoformatting so that it can guide you towards writing more idiomatic code and clearly highlight syntax errors.