Code from the paper
Staged Generic Programming
Jeremy Yallop
ICFP 2017
opam switch 4.02.1+modular-implicits-ber
opam pin add metaocaml-syb https://github.com/yallop/staged-generic-programming.git
The following examples assume that you have loaded the package and brought the instances into scope:
# #require "metaocaml-syb";;
# open Metaocaml_syb.Instances_;;
# open Metaocaml_syb.Schemes;;
# open Metaocaml_syb.Instantiate;;
# open Metaocaml_syb.Partially_static;;
# implicit module P = PS_code_list(struct type t = int end);;
# (generateQps (listify_ (fun x -> .<.~x mod 2 = 0 >.))
: ((int * bool option) list -> int list) code);;
- : ((int * bool option) list -> int list) code = .<
let rec r_69 x_70 =
match x_70 with
| [] -> []
| h_104::t_105 ->
let (x_131,y_132) = h_104 in
if (x_131 mod 2) = 0 then x_131 :: (r_69 t_105) else r_69 t_105 in
fun x_1 -> r_69 x_1>.
;;