I successfully installed ocaml-batteries-included
and findlib
.
I can do 'ocamlfind ocamlc -package batteries -c mycode.ml` without problems.
Also, if I do ocamlfind list
, I get
$ ocamlfind list
batteries (version: 2.0)
batteries.pa_comprehension (version: 2.0)
batteries.pa_comprehension.syntax (version: 2.0)
batteries.pa_llist (version: 2.0)
batteries.pa_llist.syntax (version: 2.0)
batteries.pa_string (version: 2.0)
batteries.pa_string.syntax (version: 2.0)
batteries.syntax (version: 2.0)
bigarray (version: [distributed with Ocaml])
camlp4 (version: [distributed with Ocaml])
...
The problem is using batteries
in ocaml (toplevel)
.
I have set up .ocamlinit
as told:
#use "topfind";;
Toploop.use_silently
Format.err_formatter (Filename.concat (Findlib.package_directory
"batteries") "battop.ml");;
but when I launch ocaml
, I get this:
$ ocaml
OCaml version 4.00.1
Findlib has been successfully loaded. Additional directives:
#require "package";; to load a package
#list;; to list the available packages
#camlp4o;; to load camlp4 (standard syntax)
#camlp4r;; to load camlp4 (revised syntax)
#predicates "p,q,...";; to set these predicates
Topfind.reset();; to force that packages will be reloaded
#thread;; to enable threads
Exception: Fl_package_base.No_such_package ("batteries", "").
Further, if I do #list
in ocaml toplevel
, I get
# #list;;
bigarray (version: [distributed with Ocaml])
camlp4 (version: [distributed with Ocaml])
camlp4.exceptiontracer (version: [distributed with Ocaml])
camlp4.extend (version: [distributed with Ocaml])
...
I can't see batteries
package.
What's the problem?
Is there a reason why you're not using OPAM? (https://github.com/OCamlPro/opam)
Install OPAM, switch to your favorite version of the 4.0x compiler (for example opam switch 4.00.1
), and run: opam install batteries
. I recommend doing opam install utop
and using utop
instead of the vanilla toplevel. In either case:
Put the following in your ~/.ocamlinit
#use "topfind";;
#require "batteries";;
open Batteries;;
This is all you need to get batteries working.