2

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 https://dev.realworldocaml.org/install.html 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.

enter image description here

glennsl
  • 28,186
  • 12
  • 57
  • 75
v_head
  • 759
  • 4
  • 13

1 Answers1

2

From what you've shown, it looks like you're trying to use #require and #use in an OCaml program, This is not correct. They are functions of the toplevel, but not part of the OCaml language itself.

When actually compiling or running a whole program, you'd either want to use ocamlfind or the libraries stanza in dune.

Chris
  • 26,361
  • 5
  • 21
  • 42