builds now

This commit is contained in:
Michael Zhang 2024-04-22 20:44:55 -05:00
parent ed2f598361
commit 25fbcdd0f1
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
12 changed files with 41 additions and 28 deletions

View file

@ -7,7 +7,12 @@
in {
devShell = pkgs.mkShell {
inputsFrom = with flakePkgs; [ main ];
packages = (with pkgs; [ ]) ++ (with pkgs.ocamlPackages; [ocaml-lsp ppxlib
packages = (with pkgs; [
inotify-tools
]) ++ (with pkgs.ocamlPackages; [
ocaml-lsp
ppxlib
ppx_deriving
alcotest
yojson
ezjsonm

View file

@ -1,6 +1,5 @@
(library
(name ppx_poplpaper)
(public_name ppx_poplpaper)
(kind ppx_rewriter)
(name ppx_poplpaper_lib)
(public_name ppx_poplpaper._lib)
(libraries ppxlib)
(preprocess (pps ppxlib.metaquot)))

View file

@ -1,19 +0,0 @@
(* https://tarides.com/blog/2019-05-09-an-introduction-to-ocaml-ppx-ecosystem/ *)
open Ppxlib
let expand ~ctxt:_ (expr: expression) =
expr
let ext = Extension.V3.declare
"monomorphic"
Extension.Context.expression
Ast_pattern.(single_expr_payload __)
expand
let rule = Context_free.Rule.extension ext
let () =
Driver.register_transformation
~rules:[rule]
"monomorphic"

6
rewriter/dune Normal file
View file

@ -0,0 +1,6 @@
(library
(name ppx_poplpaper)
(public_name ppx_poplpaper)
(kind ppx_deriver)
(libraries ppxlib ppx_deriving.api ppx_poplpaper_lib)
(preprocess (pps ppxlib.metaquot)))

20
rewriter/ppx_poplpaper.ml Normal file
View file

@ -0,0 +1,20 @@
(* https://tarides.com/blog/2019-05-09-an-introduction-to-ocaml-ppx-ecosystem/ *)
(* https://ocaml-ppx.github.io/ppxlib/ppxlib/writing-ppxs.html#extenders *)
open Ppxlib
let context = Extension.Context.expression
let extender_name = "monomorphic"
let extracter () = Ast_pattern.(single_expr_payload __)
let expander ~ctxt (_: expression) =
let loc = Expansion_context.Extension.extension_point_loc ctxt in
[%expr 5]
let my_extender = Extension.V3.declare extender_name context (extracter()) expander
let extender_rule = Context_free.Rule.extension my_extender
let _ = Driver.register_transformation ~rules:[extender_rule] "polycheck"

4
test/rewriter/test.ml Normal file
View file

@ -0,0 +1,4 @@
let prop0 (f : 'a -> 'b) (xs : 'a List.t) : bool =
List.length (List.map f xs) = 0
let mono_prop0 = [%monomorphic prop0]

View file

@ -1,2 +0,0 @@
let%monomorphic prop0 (f : 'a -> 'b) (xs : 'a List.t) : bool =
List.length (List.map f xs) = 0