u/Dazzling_Music_2411

▲ 14 r/ocaml+1 crossposts

Ocaml newbie - some trouble with HPLAR

Please allow me to introduce myself, I am a man of the typeless world, mainly Racket, Clojure, that sort of thing. I've been meaning to get into the typed language scene for programming language exploration, and I was a bit torn between the apparent purity of Haskell and practicality of Ocaml.

My experience level is zero, as in I've never written a single line.

In the end, what decided it for me was that I wanted to work through Harrison's "Handbook of Logic Programming and Automated Reasoning" which is supported by Ocaml code. I am also interested in some other programming paradigms (cclp), where Ocaml seems to be mentioned more than Haskell.

Anyways, I installed Ocaml according to the Cornell 3110 instructions, both for utop and VSCode, seems fine, gives me the 5.3.0 compiler environment.

My problem is that when I try to set up the supplied code for HPLAR, cd-ing into the provided directory and trying #use "init.ml" on the indicated file, all sorts of weirdnesses appear. In VSCode I can't even enter the #use line without a syntax error! Never mind, I tried from utop and from plain vanilla CLI, where I get this:

# #use "init.ml";;
Cannot find file nums.cma.
File "init.ml", line 10, characters 6-27:
10 | then (Topdirs.dir_directory "+camlp5";
           ^^^^^^^^^^^^^^^^^^^^^
Error: Unbound module Topdirs

The init.ml fike is as follows:

aaa#load "nums.cma";;                            (* For Ocaml 3.06     *)

if let v = String.sub Sys.ocaml_version 0 4 in v >= "3.10"
then (Topdirs.dir_directory "+camlp5";
      Topdirs.dir_load Format.std_formatter "camlp5o.cma")
else (Topdirs.dir_load Format.std_formatter "camlp4o.cma");;

type dummy_interactive = START_INTERACTIVE | END_INTERACTIVE;;
#use "initialization.ml";;
#use "Quotexpander.ml";;
#use "atp_interactive.ml";;

So I am left wondering if the problems are due to the older compiler version supported here, two major releases are enough time for things to change quite a bit.

I am keen to get up to speed and start on the book as soon as possible, and even though some may say - well, learn the operational basics first and then sort it out yourself (fair enough), if there is anyone who can provide some help to get this going a bit quicker, I would appreciate it very much! Many thanks.

reddit.com
u/Dazzling_Music_2411 — 4 days ago