package atdgen-codec-runtime
Runtime for atdgen generated bucklescript converters
Install
Dune Dependency
Authors
-
MMartin Jambon <martin@mjambon.com>
-
RRudi Grinberg <rudi.grinberg@gmail.com>
-
MMartin Jambon <martin@r2c.dev>
-
MMartin Jambon <github@mjambon.com>
-
IIvan Jager <aij+git@mrph.org>
-
Ooleksiy <oleksiy.golovko@ahrefs.com>
-
DDavid Sheets <sheets@alum.mit.edu>
-
RRudi Grinberg <me@rgrinberg.com>
-
MMartin Jambon <martin@esper.com>
-
JJeff Meister <nanaki@gmail.com>
-
CCaio Wakamatsu <caio.wakamatsu@ahrefs.com>
-
CCarmelo Piccione <carmelo.piccione@gmail.com>
-
DDaniel Weil <danweil68@gmail.com>
-
EEgor Chemokhonenko <egor.chemohonenko@ahrefs.com>
-
Gabriel Scherer
-
RRaman Varabets <roman.vorobets@gmail.com>
-
Ttzm <frank@boldsolutions.de>
-
MMathieu Baudet <mathieubaudet@fb.com>
-
OOleksiy Golovko <alexei.golovko@gmail.com>
-
RRauan Mayemir <rauan@mayemir.io>
-
CCarmelo Piccione <cep1@solvuu.com>
-
JJohn Billings <john@monkeynut.org>
-
LLouis Roché <louis@louisroche.net>
-
BBrendan Long <self@brendanlong.com>
-
CChris Yocum <cyocum@gmail.com>
-
LLouis Roché (Ahrefs) <louis.roche@ahrefs.com>
-
LLouis Roché <louis.roche@ahrefs.com>
-
PPavel Antoshkin <pavel.antoshkin@ahrefs.com>
-
PPierre Boutillier <pierre.boutillier@laposte.net>
-
SShon Feder <shon.feder@key.me>
-
AAnurag Soni <anuragsoni.13@gmail.com>
-
AArjun Ravi Narayan <arjunravinarayan@gmail.com>
-
AAsya-kawai <kawai-toshiki@aintek.xyz>
-
CChristophe Troestler <christophe.Troestler@umons.ac.be>
-
Damien Doligez
-
DDaniel M <dan.mntg@gmail.com>
-
DDing Xiang Fei <dingxiangfei2009@protonmail.ch>
-
FFrançois Pottier <francois.pottier@inria.fr>
-
JJavier Chavarri <javier.chavarri@gmail.com>
-
KKate <kit.ty.kate@disroot.org>
-
LLouis <louis.roche@ahrefs.com>
-
LLouis Roché <louis@cryptosense.com>
-
RRaman Varabets <raman+git@ahrefs.com>
-
SStephane Legrand <slegrand45@gmail.com>
-
VVincent Bernardoff <vb@luminar.eu.org>
-
Hhaoyang <haoyang@esper.co>
-
Ppmundkur <prashanth.mundkur@gmail.com>
-
Yygrek <ygrek@autistici.org>
Maintainers
Sources
atdgen-codec-runtime-2.4.0.tbz
sha256=9d5b2ccaa21813efc8161b8a9f4371d630837c4b991be90664c5f332e6f75adb
sha512=de470d3082025989126327f056fa9901870c49a1adfffa1fcdad80fcd6cd04a9ab46e1d713302dc5fbda289a15013fb086c0c0691a7fd86fe414d3e9d9950de6
doc/src/atdgen-codec-runtime/encode.ml.html
Source file encode.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 91 92
type 'a t = 'a -> Json.t let make f = f let encode f x = f x let bool b = `Bool b let char c = `String (String.make 1 c) let string s = `String s let unit () = `Null let float f = `Float f let int i = `Int i let list f xs = `List (List.map f xs) let array f xs = `List (Array.to_list (Array.map f xs)) let int32 s = `String (Int32.to_string s) let int64 s = `String (Int64.to_string s) type ('a, 'b) spec = { name: string ; data: 'a ; encode: 'b t } type 'a field_spec = | Optional of ('a option, 'a) spec * 'a option | Required of ('a, 'a) spec * 'a option type field = F : 'a field_spec -> field let field ?default encode ~name data = F (Required ( { name ; data ; encode }, default )) let field_o ?default encode ~name data = F (Optional ( { name ; data ; encode }, default )) let obj fields = `Assoc ( List.fold_left (fun acc (F f) -> match f with | Required ({ name; data; encode}, None) -> (name, encode data)::acc | Required ({ name; data; encode}, Some default) -> if default = data then acc else (name, encode data)::acc | Optional ({ name; data; encode}, default) -> match data, default with | None, _ -> acc | Some s, Some default -> if s = default then acc else (name, encode s)::acc | Some s, None -> (name, encode s)::acc ) [] fields ) let tuple1 f x = `Tuple [f x] let tuple2 f g (w, x) = `Tuple [f w; g x] let tuple3 f g h (w, x, y) = `Tuple [f w; g x; h y] let tuple4 f g h i (w, x, y, z) = `Tuple [f w; g x; h y;i z] let constr0 s = `Variant (s, None) let constr1 s f x = `Variant (s, Some (f x)) let contramap f g b = g (f b) let nullable f = function | None -> `Null | Some s -> f s let option_as_constr f = function | None -> `Variant ("None", None) | Some s -> `Variant ("Some", Some (f s)) let adapter (restore: Json.t -> Json.t) (writer: 'a t) x = let encoded = writer x in restore encoded
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>