package ppx_deriving_madcast
Library deriving cast functions based on their types
Install
Dune Dependency
Authors
Maintainers
Sources
v0.2.tar.gz
md5=bca83dbf5a6fb47ced07756c6cab1d9a
sha512=f2f604685649d8fc0c750adfb89d997ea62f2fd09f383dc38b4580fdbb7f96e45a637745f1f06aa1b529d6abcfea6691ef309eb32e423c780c2370aff4678950
doc/src/ppx_deriving_madcast.api/parsetree_utils.ml.html
Source file parsetree_utils.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
open Ppxlib open Parsetree open Ast_helper let mknoloc (txt : 'a) : 'a Ppxlib.Location.loc = {txt; loc = Ppxlib.Location.none} let rec equal_core_type t t' = equal_core_type_desc t.ptyp_desc t'.ptyp_desc and equal_core_type_desc t t' = match (t, t') with | ( Ptyp_any , Ptyp_any ) -> false | ( Ptyp_var v , Ptyp_var v' ) -> v = v' | ( Ptyp_arrow (l, t1, t2) , Ptyp_arrow (l', t1', t2') ) -> l = l' && equal_core_type t1 t1' && equal_core_type t2 t2' | ( Ptyp_tuple tl , Ptyp_tuple tl' ) -> List.for_all2 equal_core_type tl tl' | ( Ptyp_constr (i, tl) , Ptyp_constr (i', tl') ) -> i.txt = i'.txt && List.for_all2 equal_core_type tl tl' | ( Ptyp_object _ , Ptyp_object _ ) | ( Ptyp_class _ , Ptyp_class _ ) | ( Ptyp_alias _ , Ptyp_alias _ ) | ( Ptyp_variant _ , Ptyp_variant _ ) | ( Ptyp_poly _ , Ptyp_poly _ ) | ( Ptyp_package _ , Ptyp_package _ ) | ( Ptyp_extension _ , Ptyp_extension _ ) -> assert false | _ -> false module SSet = Set.Make(String) let variables_of_core_type t = let rec variables_of_core_type acc t = match t.ptyp_desc with | Ptyp_any -> acc | Ptyp_var x -> SSet.add x acc | Ptyp_arrow (_, t, t') -> variables_of_core_type (variables_of_core_type acc t) t' | Ptyp_tuple tl | Ptyp_constr (_, tl) -> List.fold_left variables_of_core_type acc tl | _ -> assert false in let set = variables_of_core_type SSet.empty t in SSet.fold (fun x acc -> x :: acc) set [] let universal_closure_of_core_type t = Typ.poly (List.map mknoloc (variables_of_core_type t)) t
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>