package OCanren-ppx
Implementation of miniKanren relational (logic) EDSL: PPX extensions
Install
Dune Dependency
Authors
Maintainers
Sources
0.3.0.tar.gz
sha256=eaf9624bbdbae8050eb43a48c0e79e97160b83b6f65a543ee1beca4c9f4ff4b2
sha512=e55dd7a3026b1dedcd37f55181059dfa44ad6976d241a1199246ee3c1684dcfdf1ae0c1da32165b5b2eb5748cfc57c906a0f0ebab56d03035a5bb87187a63cf7
doc/src/OCanren-ppx.internals/myhelpers.ml.html
Source file myhelpers.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
(* SPDX-License-Identifier: LGPL-2.1-or-later *) (* * OCanren PPX * Copyright (C) 2016-2022 * Dmitrii Kosarev aka Kakadu * St.Petersburg State University, JetBrains Research *) open Base open Ppxlib let lident_of_list = function | [] -> failwith "Bad argument: lident_of_list" | s :: tl -> List.fold_left tl ~init:(Lident s) ~f:(fun acc x -> Ldot (acc, x)) ;; (* TODO: maybe use Ppxlib.name_type_params_in_td ? *) let extract_names = List.map ~f:(fun (typ, _) -> match typ.ptyp_desc with | Ptyp_var s -> s | _ -> failwith (Caml.Format.asprintf "Don't know what to do with %a" Pprintast.core_type typ)) ;; open Ppxlib.Ast_builder.Default open Ppxlib.Ast_helper module Located = struct include Located (* let mknoloc txt = { txt; loc = Location.none } *) let map_loc ~f l = { l with txt = f l.txt } let sprintf ~loc fmt = Caml.Format.kasprintf (mk ~loc) fmt end module Exp = struct include Exp let mytuple ~loc ?(attrs = []) = function (* | [] -> Exp.construct (Located.mk ~loc (lident "()")) None *) | [] -> failwith "Bad argument: mytuple" | [ x ] -> x | xs -> tuple ~loc ~attrs xs ;; let apply ~loc f = function | [] -> f | xs -> apply ~loc f (List.map ~f:(fun e -> Nolabel, e) xs) ;; let lident ~loc l = pexp_ident ~loc (Located.mk ~loc (lident l)) let ident ~loc lident = pexp_ident ~loc (Located.mk ~loc lident) end let lident_of_list = function | [] -> failwith "Bad argument: lident_of_list" | s :: tl -> List.fold_left tl ~init:(Lident s) ~f:(fun acc x -> Ldot (acc, x)) ;;
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>