package validate
OCaml library enabling efficient data validation through PPX derivers and a suite of annotation-based validators
Install
Dune Dependency
Authors
Maintainers
Sources
validate-0.2.0.tbz
sha256=1654b5cce9c367a56127094dced317f865c9562599f209f70506a32b6b65154b
sha512=467ea81c0be6057ae5b8702f739e4d4f87e2707d2e09e12abd981cc2836b0f13ebab308c68954e64ea3ce89850aa0ac6df7944b596f70287fb99bdf326edcd46
doc/src/ppx_derive_validate/field.ml.html
Source file field.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
open Ppxlib type record_field = { name : string; loc_type : loc_type } and loc_type = { loc : Location.t; typ : simple_type } and simple_type = | Bool | Int | Float | String | Option of (simple_type * core_type) | Other of longident | List of (simple_type * core_type) | Tuple of (simple_type * core_type) list let rec extract_field_type label_loc (t : core_type) = let field_type = match t.ptyp_desc with | Ptyp_constr ({ txt = Lident "string"; _ }, []) -> String | Ptyp_constr ({ txt = Lident "int"; _ }, []) -> Int | Ptyp_constr ({ txt = Lident "bool"; _ }, []) -> Bool | Ptyp_constr ({ txt = Lident "float"; _ }, []) -> Float | Ptyp_constr ({ txt = Lident "option"; _ }, [ arg ]) -> Option (extract_field_type label_loc arg, arg) | Ptyp_constr ({ txt = Lident "list"; _ }, [ arg ]) -> List (extract_field_type label_loc arg, arg) | Ptyp_constr ({ txt = name; _ }, []) -> Other name | Ptyp_tuple inner_types -> Tuple (List.map (fun t -> let field_type = extract_field_type label_loc t in (field_type, t)) inner_types) | _ -> Location.raise_errorf ~loc:label_loc "Unsupported type" in field_type let extract_loc_type (t : core_type) = { loc = t.ptyp_loc; typ = extract_field_type t.ptyp_loc t } let extract_record_field (ld : label_declaration) = let name = ld.pld_name.txt in let loc_type = extract_loc_type ld.pld_type in { name; loc_type }
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>