Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for OCaml 4.14 & Camlp5 8.00 #74

Merged
merged 1 commit into from
Jan 25, 2023

Conversation

mpu
Copy link
Contributor

@mpu mpu commented Jan 16, 2023

The oldest version of OCaml available on Mac OS with M1 hardware is 4.10.2. This version does not offer a Camlp5 compatible with HOL-Light.

This patch updates pa_j.ml to support OCaml 4.14 & Camlp5 8.00.
I have only tested that #load "hol.ml";; works; in particular, I have not tested if library code and the other developments shipped with HOL-Light still work.

@jrh13
Copy link
Owner

jrh13 commented Jan 19, 2023

This is potentially very nice to have, thanks! Are you installing an ocaml 4.14.0 + camlp5 8.00 combination via opam? My opam installation (also on an ARM-based Mac) doesn't seem happy with that combination.

@aqjune
Copy link
Contributor

aqjune commented Jan 19, 2023

Hi, I was interested in trying your patch, but after running it on my Ubuntu machine I met this mystic error message:

ubuntu:~/hol-light $ ocaml -I `camlp5 -where` camlp5o.cma -init hol.ml
File "_none_", line 1:
Error: Reference to undefined global `Stream'

Do you have any idea what this error means?
My camlp5 version is 8.00.03 and camlp-streams is 5.0.1.

else if test ${CAMLP5_VERSION} = "6.06" -o ${CAMLP5_VERSION} = "6.07" -o ${CAMLP5_VERSION} = "6.08" -o ${CAMLP5_VERSION} = "6.09" -o ${CAMLP5_VERSION} = "6.10" -o ${CAMLP5_VERSION} = "6.11" -o ${CAMLP5_VERSION} = "6.12" -o ${CAMLP5_VERSION} = "6.13" -o ${CAMLP5_VERSION} = "6.14" -o ${CAMLP5_VERSION} = "6.15" -o ${CAMLP5_VERSION} = "6.16" -o ${CAMLP5_VERSION} = "6.17" ; \
then cp pa_j_3.1x_6.11.ml pa_j.ml; \
else cp pa_j_3.1x_${CAMLP5_BINARY_VERSION}.xx.ml pa_j.ml; \
else if test ${CAMLP5_BINARY_VERSION} = "8" ; \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking: can we use the elif instead of else if? It will eliminate a few fis below as well as linearly increasing indentation. :)

@mpu
Copy link
Contributor Author

mpu commented Jan 23, 2023

This is potentially very nice to have, thanks! Are you installing an ocaml 4.14.0 + camlp5 8.00 combination via opam? My opam installation (also on an ARM-based Mac) doesn't seem happy with that combination.

@jrh13 Yes, I used opam. opam list on my machine says I'm running camlp5.8.00.03 and ocaml-base-compiler.4.14.0; you maybe need to run opam update? After doing the port I realized I did not have a convenient snapshotting program though (on Linux, I use https://c9x.me/git/selfie.git).

running it on my Ubuntu machine I met this mystic error message

@aqjune To run it, I use the following ocamlinit (be sure to install ocamlfind):

#use "topfind";;
#require "camlp5";;
#load "camlp5o.cma";;

@aqjune
Copy link
Contributor

aqjune commented Jan 23, 2023

It worked, thanks!

@jrh13 jrh13 merged commit b681e74 into jrh13:master Jan 25, 2023
@jrh13
Copy link
Owner

jrh13 commented Jan 25, 2023

Thank you! This is a really useful contribution and I've merged it.
I still need to figure out my M1 machine's OCaml problems, but your update works well.

aqjune added a commit to aqjune/hol-light that referenced this pull request Jan 26, 2023
This fixes a crash in loading update_database.ml after jrh13#74.

The newly written `update_database.ml` is largely based on @chetmurthy's work:

https://github.com/chetmurthy/hol-light/blob/99d017c087ee938929d9d40a5fe75022bbee0257/update_database_6.ml

... with the following modifications to address updates in OCaml's Types module as well as
crashes when deprecated stdlib modules are to be loaded:

```
diff --git a/update_database_4.14.ml b/update_database_4.14.ml
index 79bc6fc..c2b69d4 100755
--- a/update_database_4.14.ml
+++ b/update_database_4.14.ml
@@ -17,9 +17,11 @@ open Types
 (* If the given type is simple return its name, otherwise None. *)

 let rec get_simple_type = function
-  | Tlink { desc = Tconstr (Pident p,[],_) } -> Some (Ident.name p)
+  | Tlink texpr ->
+    (match get_desc texpr with
+    | Tconstr (Pident p,[],_) -> Some (Ident.name p)
+    | d -> get_simple_type d)
   | Tconstr (Path.Pident p,  [], _) -> Some (Ident.name p)
-  | Tlink { desc = d } -> get_simple_type d
   | _ -> None;;

 (* Execute any OCaml expression given as a string. *)
@@ -45,15 +47,22 @@ let lid_cons lidopt id =
   | Some li -> Longident.Ldot(li, id)

 let it_val_1 lidopt s p vd acc =
-  if (Some "thm") = Ocaml_typing.get_simple_type vd.Types.val_type.desc then
+  if (Some "thm") = Ocaml_typing.get_simple_type (get_desc vd.Types.val_type) then
     (lid_cons lidopt s)::acc else acc

 let it_mod_1 lidopt s p md acc = (lid_cons lidopt s)::acc

 let enum0 lidopt =
-  let vl = Env.fold_values (it_val_1 lidopt) lidopt !Toploop.toplevel_env [] in
-  let ml = Env.fold_modules (it_mod_1 lidopt) lidopt !Toploop.toplevel_env [] in
-  (vl, ml)
+  try
+    let vl = Env.fold_values (it_val_1 lidopt) lidopt !Toploop.toplevel_env [] in
+    let ml = Env.fold_modules (it_mod_1 lidopt) lidopt !Toploop.toplevel_env [] in
+    (vl, ml)
+  with Not_found ->
+    (* Looking for (Longident.Lident "Stream") raises Not_found.
+       Stream is a deprecated alias module of "Stdlib.Stream", and the camlp-streams
+       package that is used by pa_hol_syntax redefines Stream, which seems to
+       confuse Env.fold_values and Env.fold_modules. *)
+    ([], [])

 let rec enum1 lidopt acc =
   match enum0 lidopt with
```

I checked that the updated `update_database.ml` works well by testing with the
`search` commands that are exhibited at the manual from `help "search"`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants