{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,9,30]],"date-time":"2026-09-30T10:00:04Z","timestamp":1790762404035,"version":"4.1.0"},"reference-count":41,"publisher":"Association for Computing Machinery (ACM)","issue":"ICFP","license":[{"start":{"date-parts":[[2023,8,30]],"date-time":"2023-08-30T00:00:00Z","timestamp":1693353600000},"content-version":"vor","delay-in-days":0,"URL":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/"}],"content-domain":{"domain":["dl.acm.org"],"crossmark-restriction":true},"short-container-title":["Proc. ACM Program. Lang."],"published-print":{"date-parts":[[2023,8,30]]},"abstract":"<jats:p>Initially present only in functional languages such as OCaml and Haskell, Algebraic Data Types (ADTs) have now become pervasive in mainstream languages, providing nice data abstractions and an elegant way to express functions through pattern matching. Unfortunately, ADTs remain seldom used in low-level programming. One reason is that their increased convenience comes at the cost of abstracting away the exact memory layout of values. Even Rust, which tries to optimize data layout, severely limits control over memory representation. In this article, we present a new approach to specify the data layout of rich data types based on a dual view: a source type, providing a high-level description available in the rest of the code, along with a memory type, providing full control over the memory layout. This dual view allows for better reasoning about memory layout, both for correctness, with dedicated validity criteria linking the two views, and for optimizations that manipulate the memory view. We then provide algorithms to compile constructors and destructors, including pattern matching, to their low-level memory representation. We prove our compilation algorithms correct, implement them in a tool called ribbit that compiles to LLVM IR, and show some early experimental results.<\/jats:p>","DOI":"10.1145\/3607858","type":"journal-article","created":{"date-parts":[[2023,8,31]],"date-time":"2023-08-31T13:40:31Z","timestamp":1693489231000},"page":"813-846","update-policy":"https:\/\/doi.org\/10.1145\/crossmark-policy","source":"Crossref","is-referenced-by-count":10,"title":["Bit-Stealing Made Legal: Compilation for Custom Memory Representations of Algebraic Data Types"],"prefix":"10.1145","volume":"7","author":[{"ORCID":"https:\/\/orcid.org\/0000-0002-9368-651X","authenticated-orcid":false,"given":"Tha\u00efs","family":"Baudon","sequence":"first","affiliation":[{"name":"University of Lyon, France \/ ENS Lyon, France \/ UCBL, France \/ CNRS, France \/ Inria, France \/ LIP, France"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0002-2107-7678","authenticated-orcid":false,"given":"Gabriel","family":"Radanne","sequence":"additional","affiliation":[{"name":"Inria, France \/ ENS Lyon, France \/ UCBL, France \/ CNRS, France \/ LIP, France"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0002-8013-1611","authenticated-orcid":false,"given":"Laure","family":"Gonnord","sequence":"additional","affiliation":[{"name":"University Grenoble Alpes, France \/ Grenoble INP, France \/ LCIS, France \/ LIP, France"}],"role":[{"vocabulary":"crossref","role":"author"}]}],"member":"320","published-online":{"date-parts":[[2023,8,31]]},"reference":[{"key":"e_1_2_1_1_1","volume-title":"ECMAScript Language Types. \". https:\/\/262.ecma-international.org\/14.0\/#sec-ecmascript-language-types [Online","year":"2023","unstructured":"2023. ECMAScript Language Types. \". https:\/\/262.ecma-international.org\/14.0\/#sec-ecmascript-language-types [Online; accessed 17-July-2023]"},{"key":"e_1_2_1_2_1","volume-title":"https:\/\/en.wikipedia.org\/w\/index.php?title=AoS_and_SoA&oldid=1068565041 [Online","author":"S","year":"2023","unstructured":"2023. AoS and SoA. https:\/\/en.wikipedia.org\/w\/index.php?title=AoS_and_SoA&oldid=1068565041 [Online; accessed 22-February-2023]"},{"key":"e_1_2_1_3_1","volume-title":"Compiling pattern matching","author":"Augustsson Lennart","unstructured":"Lennart Augustsson. 1985. Compiling pattern matching. In Functional Programming Languages and Computer Architecture, Jean-Pierre Jouannaud (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg. 368\u2013381. isbn:978-3-540-39677-2"},{"key":"e_1_2_1_4_1","unstructured":"Rod M Burstall. 1977. Design considerations for a functional programming language. The software revolution."},{"key":"e_1_2_1_5_1","doi-asserted-by":"publisher","DOI":"10.1145\/800087.802799"},{"key":"e_1_2_1_6_1","doi-asserted-by":"publisher","DOI":"10.1145\/3571240"},{"key":"e_1_2_1_7_1","doi-asserted-by":"publisher","DOI":"10.1017\/S0956796816000174"},{"key":"e_1_2_1_8_1","unstructured":"Simon Colin Rodolphe Lepigre and Gabriel Scherer. 2018. Unboxing Mutually Recursive Type Definitions in OCaml. arXiv preprint arXiv:1811.02300."},{"key":"e_1_2_1_9_1","doi-asserted-by":"publisher","DOI":"10.1145\/507635.507641"},{"key":"e_1_2_1_10_1","doi-asserted-by":"publisher","DOI":"10.1145\/1159876.1159880"},{"key":"e_1_2_1_11_1","volume-title":"ML Workshop. 13","author":"Garrigue Jacques","year":"1998","unstructured":"Jacques Garrigue. 1998. Programming with polymorphic variants. In ML Workshop. 13."},{"key":"e_1_2_1_12_1","doi-asserted-by":"publisher","DOI":"10.4204\/EPTCS.241.2"},{"key":"e_1_2_1_13_1","doi-asserted-by":"publisher","DOI":"10.1007\/978-1-4471-3573-9_7"},{"key":"e_1_2_1_14_1","doi-asserted-by":"publisher","DOI":"10.1145\/3486609.3487204"},{"key":"e_1_2_1_15_1","doi-asserted-by":"publisher","DOI":"10.1007\/3540543961_30"},{"key":"e_1_2_1_16_1","doi-asserted-by":"publisher","DOI":"10.1145\/2784731.2784748"},{"key":"e_1_2_1_17_1","doi-asserted-by":"publisher","DOI":"10.1145\/1863543.1863582"},{"key":"e_1_2_1_18_1","doi-asserted-by":"publisher","DOI":"10.1145\/3473596"},{"key":"e_1_2_1_19_1","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-030-64437-6_15"},{"key":"e_1_2_1_20_1","doi-asserted-by":"publisher","DOI":"10.1007\/BFb0024189"},{"key":"e_1_2_1_21_1","doi-asserted-by":"publisher","DOI":"10.1145\/143165.143205"},{"key":"e_1_2_1_22_1","unstructured":"Xavier Leroy and Antoine Min\u00e9. 2010. Zarith. https:\/\/archive.softwareheritage.org\/browse\/directory\/56fa3bba77ee6c8a40b4230eba576600641a4db1\/?origin_url=https:\/\/github.com\/ocaml\/Zarith&revision=e67bccbe69362866d2ce182bb4ba8a1a458cd387&snapshot=3f57262eeea9a011da7b93770318fc6411728b6a"},{"key":"e_1_2_1_23_1","unstructured":"2023. LLVM Language Reference Manual. \". http:\/\/web.archive.org\/web\/20230208202541\/https:\/\/www.llvm.org\/docs\/LangRef.html#type-system"},{"key":"e_1_2_1_24_1","doi-asserted-by":"publisher","DOI":"10.1145\/141471.141499"},{"key":"e_1_2_1_25_1","doi-asserted-by":"publisher","DOI":"10.1017\/S0956796807006223"},{"key":"e_1_2_1_26_1","doi-asserted-by":"publisher","DOI":"10.1145\/1411304.1411311"},{"key":"e_1_2_1_27_1","unstructured":"Yaron Minsky and Anil Madhavapeddy. 2021. Real World OCaml. https:\/\/dev.realworldocaml.org\/runtime-memory-layout.html"},{"key":"e_1_2_1_28_1","doi-asserted-by":"publisher","DOI":"10.1145\/99370.99377"},{"key":"e_1_2_1_29_1","doi-asserted-by":"publisher","DOI":"10.1145\/2976002.2976013"},{"key":"e_1_2_1_30_1","unstructured":"2021. RFC: Alignment niches for references types. https:\/\/github.com\/rust-lang\/rfcs\/pull\/3204"},{"key":"e_1_2_1_31_1","doi-asserted-by":"publisher","DOI":"10.1007\/BF01019462"},{"key":"e_1_2_1_32_1","volume-title":"When do match-compilation heuristics matter","author":"Scott Kevin","unstructured":"Kevin Scott and Norman Ramsey. 2000. When do match-compilation heuristics matter. University of Virginia, Charlottesville, VA."},{"key":"e_1_2_1_33_1","volume-title":"Partial Evaluation","author":"Sestoft Peter","unstructured":"Peter Sestoft. 1996. ML pattern match compilation and partial evaluation. In Partial Evaluation. Springer, 446\u2013464."},{"key":"e_1_2_1_34_1","doi-asserted-by":"publisher","DOI":"10.1145\/2517208.2517222"},{"key":"e_1_2_1_35_1","doi-asserted-by":"publisher","DOI":"10.1145\/1291151.1291159"},{"key":"e_1_2_1_36_1","unstructured":"2023. The Rust Reference. \". https:\/\/web.archive.org\/web\/20221225222340\/https:\/\/doc.rust-lang.org\/reference\/type-layout.html#the-default-representation"},{"key":"e_1_2_1_37_1","unstructured":"2023. The Rustonomicon. \". https:\/\/doc.rust-lang.org\/nomicon\/data.html"},{"key":"e_1_2_1_38_1","unstructured":"Linus Torvalds. 2023. The Linux Kernel. https:\/\/archive.softwareheritage.org\/browse\/content\/sha1_git:45b6ecde3665aa744f790cd915445fe07595181c\/?origin_url=https:\/\/github.com\/torvalds\/linux&path=include\/linux\/rbtree_types.h&release=v6.2&snapshot=de81d8ff32247a7edaa935cf0468bf16237d25c5"},{"key":"e_1_2_1_39_1","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-319-22102-1_30"},{"key":"e_1_2_1_40_1","unstructured":"Philip Wadler. 1987. Efficient compilation of pattern-matching. The implementation of functional programming languages."},{"key":"e_1_2_1_41_1","unstructured":"2023. WebKit NaN-boxing. https:\/\/archive.softwareheritage.org\/browse\/content\/sha1_git:1eec01b377e2c5e9f6a1b9ba27bdc322919256dd\/?origin_url=https:\/\/github.com\/WebKit\/WebKit&path=Source\/JavaScriptCore\/runtime\/JSCJSValue.h&revision=e7780d735de3975ec8bf854e4ed70d07c7648497&snapshot=df63564a304482d8c3aa219d0c9a1ce47dee6573##L402"}],"container-title":["Proceedings of the ACM on Programming Languages"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/dl.acm.org\/doi\/10.1145\/3607858","content-type":"unspecified","content-version":"vor","intended-application":"text-mining"},{"URL":"https:\/\/dl.acm.org\/doi\/pdf\/10.1145\/3607858","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2025,6,17]],"date-time":"2025-06-17T12:37:06Z","timestamp":1750163826000},"score":1,"resource":{"primary":{"URL":"https:\/\/dl.acm.org\/doi\/10.1145\/3607858"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2023,8,30]]},"references-count":41,"journal-issue":{"issue":"ICFP","published-print":{"date-parts":[[2023,8,30]]}},"alternative-id":["10.1145\/3607858"],"URL":"https:\/\/doi.org\/10.1145\/3607858","relation":{},"ISSN":["2475-1421"],"issn-type":[{"value":"2475-1421","type":"electronic"}],"subject":[],"published":{"date-parts":[[2023,8,30]]},"assertion":[{"value":"2023-08-31","order":2,"name":"published","label":"Published","group":{"name":"publication_history","label":"Publication History"}}]}}