builds now
This commit is contained in:
parent
ed2f598361
commit
25fbcdd0f1
12 changed files with 41 additions and 28 deletions
|
@ -7,7 +7,12 @@
|
||||||
in {
|
in {
|
||||||
devShell = pkgs.mkShell {
|
devShell = pkgs.mkShell {
|
||||||
inputsFrom = with flakePkgs; [ main ];
|
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
|
alcotest
|
||||||
yojson
|
yojson
|
||||||
ezjsonm
|
ezjsonm
|
||||||
|
|
5
lib/dune
5
lib/dune
|
@ -1,6 +1,5 @@
|
||||||
(library
|
(library
|
||||||
(name ppx_poplpaper)
|
(name ppx_poplpaper_lib)
|
||||||
(public_name ppx_poplpaper)
|
(public_name ppx_poplpaper._lib)
|
||||||
(kind ppx_rewriter)
|
|
||||||
(libraries ppxlib)
|
(libraries ppxlib)
|
||||||
(preprocess (pps ppxlib.metaquot)))
|
(preprocess (pps ppxlib.metaquot)))
|
||||||
|
|
|
@ -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
6
rewriter/dune
Normal 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
20
rewriter/ppx_poplpaper.ml
Normal 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
4
test/rewriter/test.ml
Normal 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]
|
|
@ -1,2 +0,0 @@
|
||||||
let%monomorphic prop0 (f : 'a -> 'b) (xs : 'a List.t) : bool =
|
|
||||||
List.length (List.map f xs) = 0
|
|
Loading…
Reference in a new issue