package bam-ppx
A PPX deriving generators for OCaml types
Install
Dune Dependency
Authors
Maintainers
Sources
bam-0.3.tbz
sha256=6fbb38cad09fb8062841cc67e8cdac279304b8cf1ed14746944cd45246d2a888
sha512=ad2b880c50921d77e3f190d8e48066407fdf4b9bb168a0e1094cc8ffb234740b53d494089346797d6c7e5bae28f4eb5d95e22b31f9329e3c5817bc506cd652d4
doc/src/bam_ppx/helpers.ml.html
Source file helpers.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
open Ppxlib let is_identifier_expr (expr : expression) : bool = match expr.pexp_desc with Pexp_ident _ -> true | _ -> false let rec is_type_var_used_in_core_type var_name (ct : core_type) : bool = match ct.ptyp_desc with | Ptyp_var s -> s = var_name (* Check if it matches the variable name *) | Ptyp_arrow (_, ct1, ct2) -> is_type_var_used_in_core_type var_name ct1 || is_type_var_used_in_core_type var_name ct2 | Ptyp_tuple cts -> List.exists (is_type_var_used_in_core_type var_name) cts | Ptyp_constr (_, args) -> List.exists (is_type_var_used_in_core_type var_name) args | Ptyp_alias (ct, s) -> s = var_name || is_type_var_used_in_core_type var_name ct | Ptyp_poly (_, ct) -> is_type_var_used_in_core_type var_name ct | _ -> false (* Function to check if a type variable is used in a type_declaration *) let is_type_var_used var_name (td : Parsetree.type_declaration) : bool = let is_used_in_manifest = match td.Parsetree.ptype_manifest with | Some ct -> is_type_var_used_in_core_type var_name ct | None -> false in let is_used_in_kind = match td.Parsetree.ptype_kind with | Parsetree.Ptype_abstract -> is_used_in_manifest | Parsetree.Ptype_variant constrs -> constrs |> List.map (fun c -> c.pcd_args) |> List.exists (function | Pcstr_tuple tuple -> List.exists (is_type_var_used_in_core_type var_name) tuple | Pcstr_record record -> record |> List.map (fun label -> label.pld_type) |> List.exists (is_type_var_used_in_core_type var_name) ) | Parsetree.Ptype_record lbls -> List.exists (fun l -> is_type_var_used_in_core_type var_name l.Parsetree.pld_type) lbls | Parsetree.Ptype_open -> is_used_in_manifest in is_used_in_manifest || is_used_in_kind
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>