So basically I am trying to follow these instructions https://dev.realworldocaml.org/install.html
I followed them literally. I have a working utop. I have a working VS Code environment. I can run code and everything.
We know the Base package is more efficient than the stdlib one for different reasons. For example:
In stdlib, to check if a member of a list exists, we do
List.mem "a" ["a"];;
in Base (for docs, look here https://ocaml.janestreet.com/ocaml-core/v0.12/doc/base/Base/List/index.html), we do something like this:
open Base
List.mem ["a"] "a" ~equal:String.equal;;
When I do the last in utop, I get the following error: `Error: Unbound module Base'
Now, surely Base exists, when I try to install it via opam install Base it gives Package base is already installed (current version is v0.15.1). but it won't load, what is the problem?
When I do #require "Base";; in utop, it says No such package: Base and when I do #require "base";; it loads, now I have no idea what s going on really.
Modules start with capitals, but the library is referenced with a lowercase letter. We can see the same with ocamlfind.
Or in dune.
One way of ensuring the Base module is available in utop is to launch utop with:
utop -require base.Now for opinion territory: The Base library is different from Stdlib, but more efficient is a judgment you may be too new to the language to make. The example you presented for
List.memis more flexible in Basr than in Stdlib, because the function for determing equality can be provided as an argument, but for this simple case it makes the call toList.memlonger for no benefit.Now, maybe the Base user wants to check for equality without case coming into play. They might write:
But using Stdlib I might write:
That's not awful.