package ez_api
Easy API library and tools
Install
Dune Dependency
Authors
Maintainers
Sources
2.1.0.tar.gz
md5=e1d03d141ef977fbd4521256c91431f1
sha512=51b0cc4e6afb0cd5ab55c0c40964946b79e0c2cc903b5d08c594292eec723a25e25463175d704c02fe559e2af5d95973514c248a603ad28ec0230c35ad2d6492
doc/src/ez_api/arg.ml.html
Source file arg.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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
(**************************************************************************) (* *) (* Copyright 2018-2023 OCamlPro *) (* *) (* All rights reserved. This file is distributed under the terms of the *) (* GNU Lesser General Public License version 2.1, with the special *) (* exception on linking described in the file LICENSE. *) (* *) (**************************************************************************) module Ty = struct type 'a witness = .. exception Not_equal type (_, _) eq = Eq : ('a, 'a) eq module type Ty = sig type t val witness : t witness val eq: 'a witness -> ('a, t) eq end type 'a id = (module Ty with type t = 'a) let new_id (type a) () = let module Ty = struct type t = a type 'a witness += Ty : t witness let witness = Ty let eq (type b) : b witness -> (b, t) eq = function Ty -> Eq | _ -> raise Not_equal end in (module Ty : Ty with type t = a) let eq : type a b. a id -> b id -> (a, b) eq = fun (module TyA) (module TyB) -> TyB.eq TyA.witness end type descr = { name: string ; descr: string option ; example: string option } type 'a t = { id: 'a Ty.id; destruct: string -> ('a, string) result ; construct: 'a -> string ; description: descr ; } let make ?example ?descr ~name ~destruct ~construct () = let id = Ty.new_id () in let example = match example with | None -> None | Some example -> Some (construct example) in let description = { name ; descr; example } in { description ; id ; construct ; destruct } let descr (ty: 'a t) = ty.description let int ?descr ?example name = let int_of_string s = try Ok (int_of_string s) with Failure _ -> Error (Printf.sprintf "Cannot parse integer value: %S." s) in make ?example ?descr ~name ~destruct:int_of_string ~construct:string_of_int () let float ?descr ?example name = let float_of_string s = match float_of_string_opt s with | Some f -> Ok f | None -> Error (Printf.sprintf "Cannot parse float value: %S." s) in make ?example ?descr ~name ~destruct:float_of_string ~construct:string_of_float () let int32 ?descr ?example name = let int32_of_string s = match Int32.of_string_opt s with | Some i -> Ok i | None -> Error (Printf.sprintf "Cannot parse int32 value: %S." s) in make ?example ?descr ~name ~destruct:int32_of_string ~construct:Int32.to_string () let int64 ?descr ?example name = let int64_of_string s = match Int64.of_string_opt s with | Some i -> Ok i | None -> Error (Printf.sprintf "Cannot parse int64 value: %S." s) in make ?descr ?example ~name ~destruct:int64_of_string ~construct:Int64.to_string () let string ?descr ?example name = make ?descr ?example ~name ~destruct:Result.ok ~construct:(fun s -> s) ()
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>