Skip to content

Commit 6a4e595

Browse files
committed
Remove dependency on ocaml-migrate-parsetree
(and rely on ppxlib, which thankfully offers a compatibility register function)
1 parent 82c1ca7 commit 6a4e595

File tree

10 files changed

+21
-13
lines changed

10 files changed

+21
-13
lines changed

learn-ocaml-client.opam

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ depends: [
3434
"lwt_ssl"
3535
"ocaml" {(>= "4.12") & (< "4.13~")}
3636
"ocamlfind" {build}
37-
"ocaml-migrate-parsetree" {= "1.8.0"}
3837
"ocp-indent-nlfork"
3938
"ocplib-json-typed" {>= "0.7"}
4039
"ocp-ocamlres" {>= "0.4"}

learn-ocaml-client.opam.locked

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ depends: [
7272
"ocaml" {= "4.12.1"}
7373
"ocaml-compiler-libs" {= "v0.12.4"}
7474
"ocaml-config" {= "2"}
75-
"ocaml-migrate-parsetree" {= "1.8.0"}
7675
"ocaml-options-vanilla" {= "1"}
7776
"ocaml-syntax-shims" {= "1.0.0"}
7877
"ocamlbuild" {= "0.14.1"}

learn-ocaml.opam

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ depends: [
4949
"markup-lwt"
5050
"ocaml" {(>= "4.12") & (< "4.13~")}
5151
"ocamlfind" {build}
52-
"ocaml-migrate-parsetree" {= "1.8.0"}
5352
"ocp-indent-nlfork" {>= "1.5.5"}
5453
"ocplib-json-typed" {>= "0.7"}
5554
"ocplib-json-typed-browser" {>= "0.7"}

learn-ocaml.opam.locked

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ depends: [
8080
"ocaml" {= "4.12.1"}
8181
"ocaml-compiler-libs" {= "v0.12.4"}
8282
"ocaml-config" {= "2"}
83-
"ocaml-migrate-parsetree" {= "1.8.0"}
8483
"ocaml-options-vanilla" {= "1"}
8584
"ocaml-syntax-shims" {= "1.0.0"}
8685
"ocamlbuild" {= "0.14.1"}

src/grader/introspection.ml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ let get_value lid ty =
162162
Typetexp.transl_type_scheme !Toploop.toplevel_env (Ty.obj ty) in
163163
let path, { Types.val_type; _ } =
164164
Env.find_value_by_name lid !Toploop.toplevel_env in
165-
if Ctype.moregeneral !Toploop.toplevel_env true val_type exp_type then
165+
if Ctype.is_moregeneral !Toploop.toplevel_env true val_type exp_type then
166166
Present (Obj.obj @@ Toploop.eval_value_path !Toploop.toplevel_env path)
167167
else
168168
failwith (Format.asprintf "Wrong type %a." Printtyp.type_sch val_type)
@@ -327,8 +327,14 @@ let sample_value ty =
327327
| true ->
328328
let path, { Types.val_type; _ } =
329329
Env.find_value_by_name (Longident.Lident lid) !Toploop.toplevel_env in
330-
let gty = Types.{ty with desc = Tarrow (Asttypes.Nolabel, Predef.type_unit, ty, Cok) } in
331-
if Ctype.moregeneral !Toploop.toplevel_env true val_type gty then
330+
let gty =
331+
Types.Private_type_expr.create
332+
Types.(Tarrow (Asttypes.Nolabel, Predef.type_unit, ty, Cok))
333+
~level:ty.Types.level
334+
~scope:ty.Types.scope
335+
~id:ty.Types.id
336+
in
337+
if Ctype.is_moregeneral !Toploop.toplevel_env true val_type gty then
332338
(Obj.obj @@ Toploop.eval_value_path !Toploop.toplevel_env path)
333339
else (failwith "sampler has the wrong type !")
334340
| false ->

src/ppx-metaquot/dune

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
(executable
22
(name genlifter)
3-
(libraries ppx_tools compiler-libs)
43
(modules Genlifter)
4+
(preprocess (action (run %{bin:cppo} -V OCAML:%{ocaml_version} %{input-file})))
5+
(libraries compiler-libs.common ppx_tools)
56
)
67

78
(rule

src/ppx-metaquot/exercise_ppx_main.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
* included LICENSE file for details. *)
77

88
let () =
9-
Migrate_parsetree.Driver.run_main ~exit_on_error:true ()
9+
Ppxlib.Driver.run_as_ppx_rewriter ()

src/ppx-metaquot/grader_ppx.ml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
* included LICENSE file for details. *)
77

88
let () =
9-
Migrate_parsetree.Driver.register ~name:"ppx_metaquot" (module Migrate_parsetree.OCaml_412)
10-
(fun _config _cookies -> Ppx_metaquot.Main.expander []);
9+
let mapper = Ppx_metaquot.expander [] in
10+
let impl = mapper.Ast_mapper.structure mapper in
11+
let intf = mapper.Ast_mapper.signature mapper in
12+
Ppxlib.Driver.register_transformation_using_ocaml_current_ast
13+
"ppx_metaquot" ~impl ~intf
14+
15+
let () =
1116
Ppxlib.Driver.register_transformation "print_recorder" ~impl:Printer_recorder.expand;
1217
Ppxlib.Driver.register_transformation "sample_recorder" ~impl:Sampler_recorder.expand

src/ppx-metaquot/grader_ppx_main.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
* included LICENSE file for details. *)
77

88
let () =
9-
Migrate_parsetree.Driver.run_main ~exit_on_error:true ()
9+
Ppxlib.Driver.run_as_ppx_rewriter ()

src/repo/learnocaml_precompile_exercise.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ let ocamlc ?(dir=Sys.getcwd ()) ?(opn=[]) ?(ppx=[]) ~source ~target args =
4343
if is_fresh ~dir target source then Lwt.return_unit else
4444
let args =
4545
List.fold_right (fun ppx args ->
46-
"-ppx" :: Filename.concat !grading_cmis_dir (ppx^" --as-ppx") :: args)
46+
"-ppx" :: Filename.concat !grading_cmis_dir ppx :: args)
4747
ppx args
4848
in
4949
let args = "-I" :: dir :: "-I" :: !grading_cmis_dir :: args in

0 commit comments

Comments
 (0)