z3 OCaml bindings - toplevel - ocaml

I've built z3 as described here using the ml-ng branch. Everything seems to have completed fine, except when I want to use z3 in the OCaml toplevel (I try to use the FindLib #require command to import what's needed) I get this error:
Error: The external function `n_is_null' is not available
any ideas on what this is, and how I would go about successfully using z3 in the toplevel?

I have just updated the ml-ng branch with a new set of build rules that should build and install a package that also works in the ocaml toplevel. See also the following discussion on codeplex: OCaml bindings status and compilation

Related

coq 8.11.0 incompatible with ocaml 4.10?

I am installing coq with opam as per these instructions and have gotten the error message
`No solution for coq: The following dependencies couldn't be met:
- coq → ocaml < 4.10
base of this switch (use '--unlock-base' to force)
I proceeded to switch to ocaml 4.05.0 with the following command
opam switch create with-coq 4.05.0
and could install Coq successfully, but I'd much rather use the updated version of ocaml. Is this an actual incompatibility between Coq and oCaml, or am I doing something wrong?
For added context, I am now using opam 2.0.6, ocaml version 4.05.0, and Coq version 8.11.0. My operating system is macOS. Prior, the only difference was that I tried to use ocaml 4.10.0.
Thank you!
You need the tip of the v8.11 branch or wait for 8.11.1 which should be out shortly.
You don't need to go back to 4.05.0 tho, 4.09 will work fine, tho 4.07.1+flambda is the one I recommend, see https://coq.discourse.group/t/install-notes-on-coq-and-ocaml-versions-configuration/713

OCaml's utop: importing external modules

I'm interested in introducing Angstrom, a parsing combinator library, to a project of mine.
I installed Angstrom to my system with opam as follows:
$> opam install angstrom
I also successfully compiled the project with reference to the module in question using ocamlfind:
$> ocamlbuild -use-ocamlfind -pkgs 'angstrom' project.byte
Surprisingly, I'm having trouble importing Angstrom to the utop repl. Commands like #open Angstrom indicate a value bound to the module name. I have searched for documentation of module imports from the repl, but I haven't found the result that I'm looking for.
What's the best way to reference an external module from utop?
I found an answer to my question. From utop:
utop # #require "angstrom";;
utop # open Angstrom;;
My apologies for perhaps posting prematurely, but hopefully someone will find this answer helpful in the future.

OCaml unable to load "extLib.cma" from toplevel

When I attempt to load the file extLib.cma in utop, OCaml's top level, I get the following error:
Cannot find file extLib.cma
However, if I try to install it using opam I get the following note:
Package extlib is already installed.
What am I doing wrong?
If your purpose is to interactively use some of extLib's functions then
$ utop
μ> #require "extlib";;
μ> ExtString.String.explode "ExtLib";;
- : char list = [E; x; t; L; i; b]
If it's something else, then you may need to specify the exact path to extLib.cma, and something similar to the following should work:
$ utop
μ> #load "/Users/xxx/.opam/4.02.3/lib/extlib/extLib.cma";;
where /Users/xxx is your home directory/folder; 4.02.3 is my current compiler version, set via opam switch (IIRC, it's system by default).

Telling ocamlbuild to use Core

In my project I have a file that uses Core.Std stuff, so I have run
opam install core
and added
open Core.Std
in my file.
When I run
ocamlbuild myprogram.native
it says:
Error: Unbound module Core
pointing to line with the open statement above.
So, I try this:
ocamlbuild -use-ocamlfind -pkgs core.std myprogram.native
and get the following message:
ocamlfind: Package `core.std' not found
So I thought that maybe I needed to run opam install core.std as well, but apparently there is no such thing according to opam. I also tried "open Core.Std;;" in the ocaml repl, but that did not work either. Any ideas?
You can either use corebuild which is usually shipped with this library or, you can try this:
ocamlbuild -use-ocamlfind -pkg core
P.S. use ocamlfind list command to view the list of available packages.
P.P.S. In addition to corebuild they usually ship coretop, a script that allows you to run core-enabled top-level. It uses utop underneath the hood, so make sure that you have installed it with opam install utop (if you're using opam), before your experiments.
Remove .std from your ocamlbuild cmd?

Trying to go through Lwt tutorial, but there seems to be a library problem

I'm running Ocaml 3.12 on Ubuntu installed via Godi.
I'm going through the Lwt tutorial. I've started up the toplevel and done (as instructed):
# #use "topfind";;
# #require "lwt";;
The require of "lwt" seems to be successful (no complaints about not being able to find it).
Then a bit later I try:
# Lwt_io.read_char;;
And the toplevel complains:
# Error: Reference to undefined global `Lwt_io'
When I look in ~/godi-3.12/lib/ocaml/pkg-lib/lwt I see that lwt_io.cmi and lwt_io.mli files are present. godi says I have version 2.2.1 of lwt installed.
I also tried running lwt-toplevel, but could not type anything into it...
Lwt_io module belongs to lwt.unix subpackage. Use it:
#require "lwt.unix";;