{"title":"Set-theoretic Types for Erlang","authors":"Albert Schimpf, Stefan Wehr, Annette Bieniusa","doi":"10.1145/3587216.3587220","DOIUrl":"https://doi.org/10.1145/3587216.3587220","url":null,"abstract":"Erlang is a functional programming language with dynamic typing. The language offers great flexibility for destructing values through pattern matching and dynamic type tests. Erlang also comes with a type language supporting parametric polymorphism, equi-recursive types, as well as union and a limited form of intersection types. However, type signatures only serve as documentation; there is no check that a function body conforms to its signature. Set-theoretic types and semantic subtyping fit Erlang’s feature set very well. They allow expressing nearly all constructs of its type language and provide means for statically checking type signatures. This article brings set-theoretic types to Erlang and demonstrates how existing Erlang code can be statically type checked without or with only minor modifications to the code. Further, the article formalizes the main ingredients of the type system in a small core calculus, reports on an implementation of the system, and compares it with other static type checkers for Erlang.","PeriodicalId":318613,"journal":{"name":"Proceedings of the 34th Symposium on Implementation and Application of Functional Languages","volume":"1 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2022-08-31","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"128736673","PeriodicalName":null,"FirstCategoryId":null,"ListUrlMain":null,"RegionNum":0,"RegionCategory":"","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":"","EPubDate":null,"PubModel":null,"JCR":null,"JCRName":null,"Score":null,"Total":0}
{"title":"First-Class Data Types in Shallow Embedded Domain-Specific Languages using Metaprogramming","authors":"Mart Lubbers, P. Koopman, R. Plasmeijer","doi":"10.1145/3587216.3587219","DOIUrl":"https://doi.org/10.1145/3587216.3587219","url":null,"abstract":"Functional programming languages are excellent for hosting embedded domain specific languages (eDSLs) because of their rich type systems, minimal syntax, and referential transparency. However, data types defined in the host language are not automatically available in the embedded language. To do so, all the operations on the data type must be ported to the eDSL resulting in a lot of boilerplate. This paper shows that by using metaprogramming, all first-order user-defined data types can be automatically made first class in shallow embedded DSLs. We show this by providing an implementation in Template Haskell for a typical DSL with two different semantics. Furthermore, we show that by utilising quasiquotation, there is hardly any burden on the syntax. Finally, the paper also serves as a gentle introduction to Template Haskell.","PeriodicalId":318613,"journal":{"name":"Proceedings of the 34th Symposium on Implementation and Application of Functional Languages","volume":"23 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2022-08-31","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"125318096","PeriodicalName":null,"FirstCategoryId":null,"ListUrlMain":null,"RegionNum":0,"RegionCategory":"","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":"","EPubDate":null,"PubModel":null,"JCR":null,"JCRName":null,"Score":null,"Total":0}
{"title":"Compiling a functional array language with non-semantic memory information","authors":"Philip Munksgaard, C. Oancea, Troels Henriksen","doi":"10.1145/3587216.3587218","DOIUrl":"https://doi.org/10.1145/3587216.3587218","url":null,"abstract":"We present a technique for introducing a notion of memory in the compiler representation for a parallel functional array language, in a way that allows for transformation and optimization of memory access patterns and uses, while preserving value-based semantics. Functional languages expose no notion of memory to the user. There is no explicit allocation or deallocation of memory, nor any mapping from arrays to memory locations. Instead, the compiler must infer when and where to perform allocations as well as how values should be represented in memory. Because this affects performance, an optimizing compiler will need freedom to express various memory optimizations. Typically this is done by lowering the functional language to an imperative intermediate representation with a direct notion of memory, losing the ability to use high-level functional reasoning while performing said optimizations. We present a compiler representation where memory information is non-semantic, in the sense that it does not affect the program result, but only the operational details. We start by defining a simple functional language without memory, Fun, and give it static and dynamic semantics. Next, we define an extended language, FunMem, which is Fun with non-semantic memory information in the form of lmads and an allocation statement. We give the extended language static and dynamic semantics and we provide an algorithm for transforming a Fun program into FunMem. We likewise introduce a simple imperative language Imp, which we use to illustrate how one might translate FunMem into lower-level code. Finally, we show an example of a useful transformation in FunMem, memory expansion, which is used to hoist allocations from parallel GPU kernels.","PeriodicalId":318613,"journal":{"name":"Proceedings of the 34th Symposium on Implementation and Application of Functional Languages","volume":"9 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2022-08-31","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"117013402","PeriodicalName":null,"FirstCategoryId":null,"ListUrlMain":null,"RegionNum":0,"RegionCategory":"","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":"","EPubDate":null,"PubModel":null,"JCR":null,"JCRName":null,"Score":null,"Total":0}
{"title":"The Foil: Capture-Avoiding Substitution With No Sharp Edges","authors":"D. Maclaurin, Alexey Radul, Adam Paszke","doi":"10.1145/3587216.3587224","DOIUrl":"https://doi.org/10.1145/3587216.3587224","url":null,"abstract":"Correctly manipulating program terms in a compiler is surprisingly difficult because of the need to avoid name capture. The rapier from Peyton Jones and Marlow [9] is a cutting-edge technique for fast, stateless capture-avoiding substitution for expressions represented with explicit names. It is, however, a sharp tool—its invariants are tricky and need to be maintained throughout the whole compiler that uses it. We describe the foil, an elaboration of the rapier that uses Haskell’s type system to enforce the rapier’s invariants statically, preventing a class of hard-to-find bugs, but without adding any run-time overheads.","PeriodicalId":318613,"journal":{"name":"Proceedings of the 34th Symposium on Implementation and Application of Functional Languages","volume":"3 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2022-08-31","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"129419499","PeriodicalName":null,"FirstCategoryId":null,"ListUrlMain":null,"RegionNum":0,"RegionCategory":"","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":"","EPubDate":null,"PubModel":null,"JCR":null,"JCRName":null,"Score":null,"Total":0}
Hans Hüttel, Anja Elisasen Lumholtz Nielsen, Nana Gjerulf Sandberg, Christoffer Lind Andersen, Peter Mikkelsen
{"title":"A Structure Editor with Type-Safe Copy/Paste","authors":"Hans Hüttel, Anja Elisasen Lumholtz Nielsen, Nana Gjerulf Sandberg, Christoffer Lind Andersen, Peter Mikkelsen","doi":"10.1145/3587216.3587221","DOIUrl":"https://doi.org/10.1145/3587216.3587221","url":null,"abstract":"The editor calculus of Godiksen et al [2] describes the edit primitives of a syntax-directed editor for functional programs in a simply typed lambda calculus. However, a main shortcoming is that only top-down programming is allowed, meaning that we can only construct the AST from the root. This makes it difficult to refactor previously written code without having to potentially delete and re-insert large parts of a program. The present paper modifies the calculus to not only handle programs with Hindley-Milner-style let polymorphism but also to incorporate a notion of copy/paste functionality. We present an extended semantics and a type system of the new system and prove that it remains sound: Well-typed editor expressions will always produce a well-typed program.","PeriodicalId":318613,"journal":{"name":"Proceedings of the 34th Symposium on Implementation and Application of Functional Languages","volume":"36 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2022-08-31","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"132771426","PeriodicalName":null,"FirstCategoryId":null,"ListUrlMain":null,"RegionNum":0,"RegionCategory":"","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":"","EPubDate":null,"PubModel":null,"JCR":null,"JCRName":null,"Score":null,"Total":0}
{"title":"Verified Technology Mapping in an Agda DSL for Circuit Design: Circuit refinement through gate and data concretisation","authors":"João Paulo Pizani Flor, Wouter Swierstra","doi":"10.1145/3587216.3587217","DOIUrl":"https://doi.org/10.1145/3587216.3587217","url":null,"abstract":"The use of mechanized proofs for verification of programming language metatheory is a well-established field of study, as is the application of analogous results to the design of digital circuits. Our interest resides in the use of dependent types to formalize and verify circuit transformations. In this specific paper we focus on the technology mapping step of the circuit design flow, which can be seen as a well-typed substitution of syntax for (primitive) semantics. We formalize the technology mapping refinement and show that it indeed preserves state-transition semantics, since it is compositional.","PeriodicalId":318613,"journal":{"name":"Proceedings of the 34th Symposium on Implementation and Application of Functional Languages","volume":"30 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2022-08-31","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"126010244","PeriodicalName":null,"FirstCategoryId":null,"ListUrlMain":null,"RegionNum":0,"RegionCategory":"","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":"","EPubDate":null,"PubModel":null,"JCR":null,"JCRName":null,"Score":null,"Total":0}
{"title":"On Generating Out-Of-Core GPU Code for Multi-Dimensional Array Operations","authors":"P. van Beurden, S. Scholz","doi":"10.1145/3587216.3587223","DOIUrl":"https://doi.org/10.1145/3587216.3587223","url":null,"abstract":"This paper presents the first results of our experiments for generating CUDA code that streams array operations over the elements of its array arguments from high-level specifications. We look at two classes of memory-bound array operations: map-like operations and iterative stencil computations. We investigate code patterns that stream the arguments of these operations from the host through the GPU and back taking the iterative nature of our experiments into account. We show that this setup does not only enable computations on arrays that are so big that they do not fit into the device memory of a single GPU (hence “out-of-core“), but we also demonstrate that the proposed streaming code outperforms non-streaming code versions even for smaller array sizes. For both application patterns, we observe memory throughputs that are beyond 80% of the hardware capability, irrespective of the problem sizes.","PeriodicalId":318613,"journal":{"name":"Proceedings of the 34th Symposium on Implementation and Application of Functional Languages","volume":"824 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2022-08-31","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"125085665","PeriodicalName":null,"FirstCategoryId":null,"ListUrlMain":null,"RegionNum":0,"RegionCategory":"","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":"","EPubDate":null,"PubModel":null,"JCR":null,"JCRName":null,"Score":null,"Total":0}
{"title":"Verified Causal Broadcast with Liquid Haskell","authors":"Patrick Redmond, Gan Shen, Niki Vazou, L. Kuper","doi":"10.1145/3587216.3587222","DOIUrl":"https://doi.org/10.1145/3587216.3587222","url":null,"abstract":"Protocols to ensure that messages are delivered in causal order are a ubiquitous building block of distributed systems. For instance, distributed data storage systems can use causally ordered message delivery to ensure causal consistency, and CRDTs can rely on the existence of an underlying causally-ordered messaging layer to simplify their implementation. A causal delivery protocol ensures that when a message is delivered to a process, any causally preceding messages sent to the same process have already been delivered to it. While causal delivery protocols are widely used, verification of their correctness is less common, much less machine-checked proofs about executable implementations. We implemented a standard causal broadcast protocol in Haskell and used the Liquid Haskell solver-aided verification system to express and mechanically prove that messages will never be delivered to a process in an order that violates causality. We express this property using refinement types and prove that it holds of our implementation, taking advantage of Liquid Haskell’s underlying SMT solver to automate parts of the proof and using its manual theorem-proving features for the rest. We then put our verified causal broadcast implementation to work as the foundation of a distributed key-value store.","PeriodicalId":318613,"journal":{"name":"Proceedings of the 34th Symposium on Implementation and Application of Functional Languages","volume":"27 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2022-06-29","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"121686333","PeriodicalName":null,"FirstCategoryId":null,"ListUrlMain":null,"RegionNum":0,"RegionCategory":"","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":"","EPubDate":null,"PubModel":null,"JCR":null,"JCRName":null,"Score":null,"Total":0}
{"title":"Proceedings of the 34th Symposium on Implementation and Application of Functional Languages","authors":"","doi":"10.1145/3587216","DOIUrl":"https://doi.org/10.1145/3587216","url":null,"abstract":"","PeriodicalId":318613,"journal":{"name":"Proceedings of the 34th Symposium on Implementation and Application of Functional Languages","volume":"56 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"1900-01-01","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"121732823","PeriodicalName":null,"FirstCategoryId":null,"ListUrlMain":null,"RegionNum":0,"RegionCategory":"","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":"","EPubDate":null,"PubModel":null,"JCR":null,"JCRName":null,"Score":null,"Total":0}